Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
powerlink
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
powerlink
Commits
5286292b
Commit
5286292b
authored
Dec 18, 2020
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove use of nano_c, add lib.c for a simple malloc/free.
parent
b605ce0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
9 deletions
+56
-9
Makefile
apps/hydra_app/Makefile
+6
-9
lib.c
apps/hydra_app/lib.c
+50
-0
No files found.
apps/hydra_app/Makefile
View file @
5286292b
CROSS_COMPILE_TARGET
?=
/home/mattia/riscv32-nanolib/gnu-mcu-eclipse/riscv-none-gcc/8.1.0-2-20181019-0952/bin/riscv-none-embed
-
CROSS_COMPILE_TARGET
?=
riscv32-elf
-
openPOWERLINK
=
../..
#CROSS_COMPILE_TARGET ?= /home/mattia/riscv-toolchain/riscv/bin/riscv32-elf-
#CFLAGS += -mabi=ilp32 -march=rv32im -O2 -lgcc -lc
CFLAGS
+=
-mabi
=
ilp32
-march
=
rv32i
-Os
-ffunction-sections
-fdata-sections
-
-specs
=
nano.specs
--specs
=
nosys.specs
-
lgcc
-lc
-Wl
,--gc-sections
CFLAGS
+=
-mabi
=
ilp32
-march
=
rv32i
-Os
-ffunction-sections
-fdata-sections
-lgcc
-lc
-Wl
,--gc-sections
CFLAGS
+=
-I
./
CFLAGS
+=
-I
$(openPOWERLINK)
/stack/include/
CFLAGS
+=
-I
$(openPOWERLINK)
/stack/proj/generic/liboplkcn
...
...
@@ -14,6 +14,8 @@ CFLAGS += -I$(openPOWERLINK)/stack/src/arch
CFLAGS
+=
-D__URV__
-DCONFIG_PCP
=
TRUE
-DNDEBUG
LDFLAGS
=
-T
powerlink.ld
-nostdlib
-lgcc
-lc
CC
=
$(CROSS_COMPILE_TARGET)
gcc
LD
=
$(CROSS_COMPILE_TARGET)
ld
OBJDUMP
=
$(CROSS_COMPILE_TARGET)
objdump
...
...
@@ -25,12 +27,7 @@ PL_URV_ENV ?= ./
BUILDDIR
?=
build
OBJDIR
:=
$(PL_URV_ENV)
OBJS
:=
crt0.o
OBJS
+=
irq.o
#OBJS += eth_config.o
OBJS
+=
app.o
OBJS
+=
event.o
OBJS
+=
main.o
OBJS
:=
crt0.o main.o app.o event.o irq.o lib.o
OBJDIR
+=
stack/src/arch/urv
OBJS
+=
stack/src/arch/urv/lock-localnoos.o
...
...
@@ -194,7 +191,7 @@ $(BUILDDIR)/%.o: %.c
$(CC)
-c
-o
$@
$(CFLAGS)
$<
main
:
$(OBJS_BUILD) powerlink.ld
$(CC)
-o
$@
-nostartfiles
$(CFLAGS)
$(OBJS_BUILD)
-T
powerlink.ld
$(CC)
-o
$@
-nostartfiles
$(CFLAGS)
$(OBJS_BUILD)
$(LDFLAGS)
main-text.bin
:
main
riscv32-elf-objcopy
-j
.text
-O
binary
$<
$@
...
...
apps/hydra_app/lib.c
0 → 100644
View file @
5286292b
#include <stdlib.h>
extern
char
_end
;
static
char
*
next
=
&
_end
;
#define BUSY 1
void
*
malloc
(
size_t
len
)
{
void
*
res
;
/* Align. */
len
=
(
len
+
3
)
&
~
3U
;
/* Try to find a free block. */
res
=
&
_end
;
while
(
res
!=
next
)
{
/* Read block length. */
unsigned
l
=
*
(
unsigned
*
)
res
;
/* Get block start address. */
res
+=
sizeof
(
unsigned
);
/* If block is free and if length match, return it. */
if
(
l
==
len
)
return
res
;
/* Next block. */
res
+=
l
&
~
BUSY
;
}
/* No free block. */
*
(
unsigned
*
)
next
=
len
|
BUSY
;
res
=
next
+
sizeof
(
unsigned
);
next
=
res
+
len
;
return
res
;
}
void
free
(
void
*
ptr
)
{
if
(
ptr
==
NULL
)
return
;
/* Just clear the busy bit. */
ptr
-=
sizeof
(
unsigned
);
*
(
unsigned
*
)
ptr
=
*
(
unsigned
*
)
ptr
&
~
BUSY
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment