duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 73d94c12e9e463230e1f1cf265c2ae4e263f9009
parent a3a37c89e71d24cb761a78b8cb74bdf9ba9ee4cb
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed, 21 Jun 2023 13:44:17 -0400

rpi: on a regular boot sequence!

Diffstat:
Mbuildrpi.fs | 1+
Mfs/doc/hw/arm/rpi/rpi.txt | 6++++--
Mfs/lib/diag.fs | 2+-
Mfs/lib/scratch.fs | 2+-
Mfs/xcomp/arm/rpi/build.fs | 9+--------
Mfs/xcomp/arm/rpi/init.fs | 6+++---
Mfs/xcomp/i386/pc/build.fs | 7-------
Mfs/xcomp/tools.fs | 8++++++++
8 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/buildrpi.fs b/buildrpi.fs @@ -6,4 +6,5 @@ mydrv DriveFile :new spitBoot S" rpifat.img" mountImage ( drv ) const mydrv mydrv 2796 setupFAT value myfat +S" /xcomp/arm/rpi/init.fs" S" /xcomp/init.fs" myfat combineInit bye diff --git a/fs/doc/hw/arm/rpi/rpi.txt b/fs/doc/hw/arm/rpi/rpi.txt @@ -27,8 +27,10 @@ bit. Mine is this: uart_2ndstage=1 device_tree= -Afterwards, you'll need to mount `rpifat.img` and copy all its contents to the -SD card's FAT. +Afterwards, you'll need to copy everything from the project's `fs` subfolder +into the SD card. The `init.fs` file at the root of the SD card also needs to +be created. It's a concatenation of `/xcomp/arm/rpi/init.fs` and +`/xcomp/init.fs`, which you can of course adjust to your own liking. Then, plug your tty-UART adapter to the proper GPIO pins and power up the device (powering up through the TTY adapter itself works for me). After the 2nd diff --git a/fs/lib/diag.fs b/fs/lib/diag.fs @@ -5,7 +5,7 @@ : .S ( -- ) scnt rcnt swap S" PS %b RS %b -- " console :printf stack? psdump ; : .free - here ['] 2drop ( first word in boot.fs ) - .sz ." used " + here ['] : ( first word in bootlo.fs ) - .sz ." used " HEREMAX @ here - .sz ." free" ; : dump ( a -- ) \ dump 8 lines of data after "a" diff --git a/fs/lib/scratch.fs b/fs/lib/scratch.fs @@ -18,7 +18,7 @@ extends Allocator struct[ Scratchpad : _)buf ( self -- a ) bi :buf( | size + ; : _findspace ( self -- a ) :buf( ; : :new ( size -- pad ) - here 0 ( ptr ) , ['] _)buf , ['] _findspace , + here# 0 ( ptr ) , ['] _)buf , ['] _findspace , over ( size ) , ( size pad ) swap allot dup :reset ; : :usedsz bi ptr | :buf( - ; diff --git a/fs/xcomp/arm/rpi/build.fs b/fs/xcomp/arm/rpi/build.fs @@ -4,20 +4,13 @@ xbindict orgifydict here org - value kernellen org value kernel -: spitfile ( fpath dst -- ) >r - curpath :find# Path :open begin ( fc ) - begin dup IO :getc keepc? until - dup 0>= while r@ IO :putc repeat ( fc c ) - drop File :close rdrop ; - : spitBoot ( iohdl -- ) >r \ V1=iohdl ." Putting kernel in place\n" kernel kernellen V1 IO :write S" /xcomp/bootlo.fs" V1 spitfile - S" /drv/rpi/uart.fs" V1 spitfile S" /drv/rpi/emmc.fs" V1 spitfile S" /lib/drivelo.fs" V1 spitfile S" /fs/fatlo.fs" V1 spitfile S" /xcomp/arm/rpi/glue.fs" V1 spitfile - S" /xcomp/arm/rpi/init.fs" V1 spitfile + S" /xcomp/boothi.fs" V1 spitfile r> IO :flush ; diff --git a/fs/xcomp/arm/rpi/init.fs b/fs/xcomp/arm/rpi/init.fs @@ -1,9 +1,9 @@ +: ARCH S" arm" ; + +f<< /drv/rpi/uart.fs uart$ : _:emit ( c self -- ) drop uart! ; ' _:emit ByteWriter :new dup to console writeio to stdio writeio f<< /sys/kbd.fs ' uart@? ' key? realias -?f<< /lib/fmt.fs -?f<< /sys/rdln.fs -: init ." Dusk OS\n" rdln$ stdio$ quit ; init diff --git a/fs/xcomp/i386/pc/build.fs b/fs/xcomp/i386/pc/build.fs @@ -12,13 +12,6 @@ xbindict orgifydict here org - value kernellen org value kernel -: combineInit ( fname1 fname2 fat -- ) >r swap >r >r \ V1=fat V2=f1 V3=f2 - 0 S" init.fs" V1 Filesystem :?newfile V1 swap Path :new - V2 bootfs :self 0 Path :new Path :find# Path :copyfile - V3 bootfs :self 0 Path :new Path :find# - S" /init.fs" V1 0 Path :new Path :find# Path :appendfile - 2rdrop rdrop ; - : setupMBR ( drv -- ) ." Putting MBR in place\n" >r 0 here r@ Drive :sec@ diff --git a/fs/xcomp/tools.fs b/fs/xcomp/tools.fs @@ -65,3 +65,11 @@ LF value _last begin dup IO :getc keepc? until dup 0>= while r@ IO :putc repeat ( fc c ) drop File :close rdrop ; + +: combineInit ( fname1 fname2 fat -- ) >r swap >r >r \ V1=fat V2=f1 V3=f2 + 0 S" init.fs" V1 Filesystem :?newfile V1 swap Path :new + V2 bootfs :self 0 Path :new Path :find# Path :copyfile + V3 bootfs :self 0 Path :new Path :find# + S" /init.fs" V1 0 Path :new Path :find# Path :appendfile + 2rdrop rdrop ; +