From af0d584e363a6c10abfceab9ab9ddefea8d87972 Mon Sep 17 00:00:00 2001 From: Pierre Alain Date: Sun, 24 Nov 2024 13:39:00 +0100 Subject: [PATCH 1/4] - fix the filesystem build procedure for filesystem on the flash device - add a macro to allow selecting the root device at the kernel compile time - remove blkdiscard as it does not compile --- Kernel/platform/platform-esp8266/Makefile | 4 +++- Kernel/platform/platform-esp8266/README.md | 20 ++++++++++++++----- Kernel/platform/platform-esp8266/config.h | 7 +++++++ .../platform/platform-esp8266/update-flash.sh | 4 ++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Kernel/platform/platform-esp8266/Makefile b/Kernel/platform/platform-esp8266/Makefile index 1b6c5cd666..7281e6a623 100644 --- a/Kernel/platform/platform-esp8266/Makefile +++ b/Kernel/platform/platform-esp8266/Makefile @@ -72,7 +72,7 @@ image.elf: kernel.ld addresses.ld $(KOBJS) $(CROSS_CC) -T kernel.ld -T addresses.ld -flto -mlongcalls -nostdlib -o image.elf \ $(KOBJS) -filesystem.img:: +filesystem.img: ./update-flash.sh filesystem.ftl: filesystem.img @@ -81,6 +81,8 @@ filesystem.ftl: filesystem.img filesystem.elf: filesystem.ftl xtensa-lx106-elf-objcopy -I binary -O elf32-xtensa-le --change-section-vma .data=0x40220000 filesystem.ftl filesystem.elf + xtensa-lx106-elf-ld -Tdata 0x40220000 -o filesystem2.elf filesystem.elf + mv filesystem2.elf filesystem.elf fburn: filesystem.elf esptool elf2image filesystem.elf diff --git a/Kernel/platform/platform-esp8266/README.md b/Kernel/platform/platform-esp8266/README.md index 29c1d9ec8b..6233ed52fc 100644 --- a/Kernel/platform/platform-esp8266/README.md +++ b/Kernel/platform/platform-esp8266/README.md @@ -19,8 +19,18 @@ for further file storage and swap. ## Building +The kernel needs to know the boot device, therefore, depending on your setup, +you will need to run one of the following. If your root device is the flash: ``` -make TARGET=esp866 kernel diskimage +make TARGET=esp866 DEFAULT_BOOT=hda kernel +``` +If your root device in the SD card: +``` +make TARGET=esp866 DEFAULT_BOOT=hdb1 kernel diskimage +``` +Then you can build the application and the filesystem: +``` +make TARGET=esp866 diskimage ``` You need the `xtensa-lx106-elf` gcc toolchain --- install the @@ -63,13 +73,13 @@ Remember to also connect the SD card's GND to any ESP8266 GND pin and Vcc to The console is UART0, and runs at 115200 baud. -Doing `make -C Kernel/platform-esp8266 burn` will flash the kernel onto the device -connected on `/dev/ttyUSB0` with this command: +Doing `make -C Kernel/platform/platform-esp8266 burn` will flash the kernel +onto the device connected on `/dev/ttyUSB0` with this command: `esptool --port /dev/ttyUSB0 write_flash 0x00000 image.elf-0x00000.bin 0x10000 image.elf-0x10000.bin -ff 80m -fm dio' -Doing `make -C Kernel/platform-esp8266 fburn` will flash the filesystem onto -the device in the same manner. +Doing `make -C Kernel/platform/platform-esp8266 fburn` will flash the +filesystem onto the device in the same manner. ## Swap diff --git a/Kernel/platform/platform-esp8266/config.h b/Kernel/platform/platform-esp8266/config.h index 22f5181120..e74633ac17 100644 --- a/Kernel/platform/platform-esp8266/config.h +++ b/Kernel/platform/platform-esp8266/config.h @@ -92,7 +92,14 @@ extern uint8_t _code_top[]; /* We need a tidier way to do this from the loader */ #define CMDLINE NULL /* Location of root dev name */ +#if DEFAULT_BOOT==hda +#define BOOTDEVICE 0x0000 /* hda */ +#elif DEFAULT_BOOT==hdb1 #define BOOTDEVICE 0x0011 /* hdb1 */ +#else +#error "You must call make with either DEFAULT_BOOT=hda or DEFAULT_BOOT=hdb1" +#endif + #define SWAPDEV (swap_dev) /* wherever */ #define CONFIG_DYNAMIC_SWAP diff --git a/Kernel/platform/platform-esp8266/update-flash.sh b/Kernel/platform/platform-esp8266/update-flash.sh index de36fc82c1..0a49a50f6d 100755 --- a/Kernel/platform/platform-esp8266/update-flash.sh +++ b/Kernel/platform/platform-esp8266/update-flash.sh @@ -91,7 +91,7 @@ cd /bin bget ../../../Applications/util/banner bget ../../../Applications/util/basename bget ../../../Applications/util/bd -bget ../../../Applications/util/blkdiscard +# bget ../../../Applications/util/blkdiscard bget ../../../Applications/util/cal bget ../../../Applications/util/cat bget ../../../Applications/util/chgrp @@ -175,7 +175,7 @@ bget ../../../Applications/util/yes chmod 0755 banner chmod 0755 basename chmod 0755 bd -chmod 0755 blkdiscard +# chmod 0755 blkdiscard chmod 0755 cal chmod 0755 cat chmod 0755 chgrp From 099a37f0fbe207648af86c48a9b31a43ea64ab41 Mon Sep 17 00:00:00 2001 From: Pierre Alain <65669679+palainp@users.noreply.github.com> Date: Sun, 24 Nov 2024 15:27:16 +0100 Subject: [PATCH 2/4] Update README.md --- Kernel/platform/platform-esp8266/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/platform/platform-esp8266/README.md b/Kernel/platform/platform-esp8266/README.md index 6233ed52fc..fba5cc4f35 100644 --- a/Kernel/platform/platform-esp8266/README.md +++ b/Kernel/platform/platform-esp8266/README.md @@ -26,7 +26,7 @@ make TARGET=esp866 DEFAULT_BOOT=hda kernel ``` If your root device in the SD card: ``` -make TARGET=esp866 DEFAULT_BOOT=hdb1 kernel diskimage +make TARGET=esp866 DEFAULT_BOOT=hdb1 kernel ``` Then you can build the application and the filesystem: ``` From 905b8a82823323c28a611446da86696961e36468 Mon Sep 17 00:00:00 2001 From: Pierre Alain Date: Sun, 24 Nov 2024 20:45:41 +0100 Subject: [PATCH 3/4] fix default boot device selection and revert blkdiscard --- Kernel/platform/platform-esp8266/README.md | 14 ++++---------- Kernel/platform/platform-esp8266/config.h | 7 +++---- Kernel/platform/platform-esp8266/update-flash.sh | 4 ++-- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Kernel/platform/platform-esp8266/README.md b/Kernel/platform/platform-esp8266/README.md index fba5cc4f35..98a830769e 100644 --- a/Kernel/platform/platform-esp8266/README.md +++ b/Kernel/platform/platform-esp8266/README.md @@ -20,17 +20,11 @@ for further file storage and swap. ## Building The kernel needs to know the boot device, therefore, depending on your setup, -you will need to run one of the following. If your root device is the flash: +you will need to run one of the following. If your root device is the flash, +you must edit Kernel/platform/platform-esp8266/config.h. +Otherwise, if your root device is the SD card, the default is fine for you. ``` -make TARGET=esp866 DEFAULT_BOOT=hda kernel -``` -If your root device in the SD card: -``` -make TARGET=esp866 DEFAULT_BOOT=hdb1 kernel -``` -Then you can build the application and the filesystem: -``` -make TARGET=esp866 diskimage +make TARGET=esp866 kernel diskimage ``` You need the `xtensa-lx106-elf` gcc toolchain --- install the diff --git a/Kernel/platform/platform-esp8266/config.h b/Kernel/platform/platform-esp8266/config.h index e74633ac17..f00900347a 100644 --- a/Kernel/platform/platform-esp8266/config.h +++ b/Kernel/platform/platform-esp8266/config.h @@ -92,12 +92,11 @@ extern uint8_t _code_top[]; /* We need a tidier way to do this from the loader */ #define CMDLINE NULL /* Location of root dev name */ -#if DEFAULT_BOOT==hda #define BOOTDEVICE 0x0000 /* hda */ -#elif DEFAULT_BOOT==hdb1 +//#define BOOTDEVICE 0x0011 /* hdb1 */ +#ifndef BOOTDEVICE #define BOOTDEVICE 0x0011 /* hdb1 */ -#else -#error "You must call make with either DEFAULT_BOOT=hda or DEFAULT_BOOT=hdb1" +#warning "Default boot device is hdb1, if you want to change that you can edit Kernel/platform/platform-esp8266/config.h" #endif #define SWAPDEV (swap_dev) /* wherever */ diff --git a/Kernel/platform/platform-esp8266/update-flash.sh b/Kernel/platform/platform-esp8266/update-flash.sh index 0a49a50f6d..de36fc82c1 100755 --- a/Kernel/platform/platform-esp8266/update-flash.sh +++ b/Kernel/platform/platform-esp8266/update-flash.sh @@ -91,7 +91,7 @@ cd /bin bget ../../../Applications/util/banner bget ../../../Applications/util/basename bget ../../../Applications/util/bd -# bget ../../../Applications/util/blkdiscard +bget ../../../Applications/util/blkdiscard bget ../../../Applications/util/cal bget ../../../Applications/util/cat bget ../../../Applications/util/chgrp @@ -175,7 +175,7 @@ bget ../../../Applications/util/yes chmod 0755 banner chmod 0755 basename chmod 0755 bd -# chmod 0755 blkdiscard +chmod 0755 blkdiscard chmod 0755 cal chmod 0755 cat chmod 0755 chgrp From ccde82b9728890c5b081072ad22d3752c7f0f385 Mon Sep 17 00:00:00 2001 From: Pierre Alain <65669679+palainp@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:25:23 +0100 Subject: [PATCH 4/4] do not default boot on flash --- Kernel/platform/platform-esp8266/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/platform/platform-esp8266/config.h b/Kernel/platform/platform-esp8266/config.h index f00900347a..4883c86b72 100644 --- a/Kernel/platform/platform-esp8266/config.h +++ b/Kernel/platform/platform-esp8266/config.h @@ -92,7 +92,7 @@ extern uint8_t _code_top[]; /* We need a tidier way to do this from the loader */ #define CMDLINE NULL /* Location of root dev name */ -#define BOOTDEVICE 0x0000 /* hda */ +//#define BOOTDEVICE 0x0000 /* hda */ //#define BOOTDEVICE 0x0011 /* hdb1 */ #ifndef BOOTDEVICE #define BOOTDEVICE 0x0011 /* hdb1 */