Skip to content

Commit

Permalink
Ox64 Build is different
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Feb 12, 2024
1 parent 8421853 commit 221f805
Show file tree
Hide file tree
Showing 5 changed files with 626,915 additions and 5,340 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ Initial RAM Disk (initrd) is now 17 MB...
-rw-r--r-- 1 17363968 Feb 12 13:06 /Users/Luppy/ox64/nuttx/initrd
```
We [increase the RAM Disk Region from](https://github.com/lupyuen2/wip-pinephone-nuttx/commit/e5e2452920a6f0e1379a55df943e8f3c74d25274) 16 MB to 32 MB.
We [increase the RAM Disk Region from](https://github.com/lupyuen2/wip-pinephone-nuttx/commit/e5e2452920a6f0e1379a55df943e8f3c74d25274) 16 MB to 40 MB.
But QuickJS crashes on Ox64...
Expand Down
73 changes: 54 additions & 19 deletions nuttx/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
## TODO: Set PATH
export PATH="$HOME/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/bin:$PATH"

# target=$HOME/riscv
target=$HOME/ox64
# target=riscv
target=ox64

set -e # Exit when any command fails
set -x # Echo commands
Expand Down Expand Up @@ -47,10 +47,10 @@ nuttx_options=" \
-mcmodel=medany \
-march=rv64imafdc \
-mabi=lp64d \
-isystem $target/apps/import/include \
-isystem $target/apps/import/include \
-isystem $HOME/$target/apps/import/include \
-isystem $HOME/$target/apps/import/include \
-D__NuttX__ \
-I "$target/apps/include" \
-I "$HOME/$target/apps/include" \
"

## Compile the NuttX App
Expand Down Expand Up @@ -146,17 +146,19 @@ riscv64-unknown-elf-gcc \
libbf.c
fi

## Link the NuttX App
## For riscv-none-elf-ld: "rv64imafdc_zicsr/lp64d"
## For riscv64-unknown-elf-ld: "rv64imafdc/lp64d
riscv64-unknown-elf-ld \
--oformat elf64-littleriscv \
-r \
-e main \
-T /Users/Luppy/ox64/nuttx/binfmt/libelf/gnu-elf.ld \
-r \
-e _start \
-Bstatic \
-T$target/apps/import/scripts/gnu-elf.ld \
-L$target/apps/import/libs \
-L "$HOME/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/lib/gcc/riscv64-unknown-elf/10.2.0/rv64imafdc/lp64d" \
$target/apps/import/startup/crt0.o \
-T/Users/Luppy/ox64/apps/import/scripts/gnu-elf.ld \
-L/Users/Luppy/ox64/apps/import/libs \
-L "/Users/Luppy/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d" \
-L "/Users/Luppy/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/rv64imafdc/lp64d" \
/Users/Luppy/ox64/apps/import/startup/crt0.o \
.obj/qjs.o \
.obj/repl.o \
.obj/quickjs.o \
Expand All @@ -172,22 +174,55 @@ riscv64-unknown-elf-ld \
-lmm \
-lc \
-lproxies \
-lgcc \
-lm \
$target/apps/libapps.a \
$HOME/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/lib/gcc/riscv64-unknown-elf/10.2.0/rv64imafdc/lp64d/libgcc.a \
-lgcc /Users/Luppy/ox64/apps/libapps.a \
/Users/Luppy/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/rv64imafdc/lp64d/libgcc.a \
--end-group \
-o $target/apps/bin/qjs \
-o $HOME/$target/apps/bin/qjs \
-Map nuttx/qjs.map

## Link the NuttX App
## For riscv-none-elf-ld: "rv64imafdc_zicsr/lp64d"
## For riscv64-unknown-elf-ld: "rv64imafdc/lp64d
# riscv64-unknown-elf-ld \
# --oformat elf64-littleriscv \
# -e _start \
# -Bstatic \
# -T$HOME/$target/apps/import/scripts/gnu-elf.ld \
# -L$HOME/$target/apps/import/libs \
# -L "$HOME/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/lib/gcc/riscv64-unknown-elf/10.2.0/rv64imafdc/lp64d" \
# $HOME/$target/apps/import/startup/crt0.o \
# .obj/qjs.o \
# .obj/repl.o \
# .obj/quickjs.o \
# .obj/libregexp.o \
# .obj/libunicode.o \
# .obj/cutils.o \
# .obj/quickjs-libc.o \
# .obj/libbf.o \
# .obj/qjscalc.o \
# .obj/arch_atomic.o \
# .obj/stub.o \
# --start-group \
# -lmm \
# -lc \
# -lproxies \
# -lgcc \
# -lm \
# $HOME/$target/apps/libapps.a \
# $HOME/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-apple-darwin/lib/gcc/riscv64-unknown-elf/10.2.0/rv64imafdc/lp64d/libgcc.a \
# --end-group \
# -o $HOME/$target/apps/bin/qjs \
# -Map nuttx/qjs.map

## Show the size
riscv64-unknown-elf-size $target/apps/bin/qjs
riscv64-unknown-elf-size $HOME/$target/apps/bin/qjs

## Dump the disassembly
riscv64-unknown-elf-objdump \
-t -S --demangle --line-numbers --wide \
$target/apps/bin/qjs \
>nuttx/qjs.S \
$HOME/$target/apps/bin/qjs \
>nuttx/qjs-$target.S \
2>&1

## Test with QEMU
Expand Down
8 changes: 4 additions & 4 deletions nuttx/qemu.log
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
spawn qemu-system-riscv64 -semihosting -M virt,aclint=on -cpu rv64 -smp 8 -bios none -kernel nuttx -nographic
ABC[ 0.020000] board_userled_all: ledset=0x0
[ 0.022000] board_userled_all: led=0, val=0
[ 0.023000] board_userled_all: led=1, val=0
[ 0.023000] board_userled_all: led=2, val=0
ABC[ 0.016000] board_userled_all: ledset=0x0
[ 0.018000] board_userled_all: led=0, val=0
[ 0.018000] board_userled_all: led=1, val=0
[ 0.019000] board_userled_all: led=2, val=0

NuttShell (NSH) NuttX-12.4.0-RC0
nsh> qjs
Expand Down
Loading

0 comments on commit 221f805

Please sign in to comment.