Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizing the filesystem / partitions for N16R8 #16

Open
johandevlabs opened this issue Sep 18, 2024 · 4 comments
Open

Customizing the filesystem / partitions for N16R8 #16

johandevlabs opened this issue Sep 18, 2024 · 4 comments

Comments

@johandevlabs
Copy link

I have a ESP32-S3 N16R8 (https://www.robotics.org.za/ESP32-S3-N16R8).

The rebuild-esp32s3-linux-wifi.sh scripts works flawlessly on my device, but it is configured to N8R8 (with 8MB flash total).

How do I reconfigure the build to make full use of the 16MB flash? Ideally, I would like to allocate an additional 8MB to the rootfs (and make it read/write) so I can place files in the /root folder. Is this possible?

~ # ls /dev/mtd*
/dev/mtd0       /dev/mtd2ro     /dev/mtd5       /dev/mtdblock3
/dev/mtd0ro     /dev/mtd3       /dev/mtd5ro     /dev/mtdblock4
/dev/mtd1       /dev/mtd3ro     /dev/mtdblock0  /dev/mtdblock5
/dev/mtd1ro     /dev/mtd4       /dev/mtdblock1
/dev/mtd2       /dev/mtd4ro     /dev/mtdblock2
~ # df -h
Filesystem                Size      Used Available Use% Mounted on
mtd:rootfs                4.2M      4.2M         0 100% /
mtd:etc                 448.0K    216.0K    232.0K  48% /etc
@jcmvbkbc
Copy link
Owner

I would like to allocate an additional 8MB to the rootfs (and make it read/write) so I can place files in the /root folder.
Is this possible?

Making it rw -- no, not without losing the XIP capability. But you could create a new partition, format it however you like
and mount it to /root or elsewhere. For that you'd need to start with the partition table in the bootloader, make your version based on the default and use it in the bootloader configuration. You'd also need to change the selected flash size in the config.
Then you can add that new partition to the /etc/fstab in the buildroot rootfs overlay here. And then you'd either need to build an image for that file system and flash it like the other partitions, or reconfigure the buildroot to include FLASH tools and do formatting from the running linux system.

@johandevlabs
Copy link
Author

Thanks @jcmvbkbc, this makes sense.

For context, I am trying to include Micropython and Netcat (nc). First step for me was to expand the rootfs so I have space for the additional packages. I forked your esp-hosted fork and configured it for N16R8 https://github.com/johandevlabs/esp-hosted/tree/ipc-5.1.1_N16R8 ). It is working now! :) I will tinker more with adding a new partition later.

/etc # df -h
Filesystem                Size      Used Available Use% Mounted on
mtd:rootfs                6.5M      6.5M         0 100% /
mtd:etc                 448.0K    220.0K    228.0K  49% /etc

I have test nc and it works for POST requests. I have also tested micropython, unfortunately it does not work yet

/etc # micropython 
[ 1738.801573] micropython: page allocation failure: order:9, mode:0xcc0(GFP_KERNEL), nodemask=(null)
[ 1738.802777] CPU: 0 PID: 214 Comm: micropython Not tainted 6.10.0-rc2 #1
[ 1738.807069] Stack:
[ 1738.809199] > 00000100 00000000 3df69bb0 423be718
[ 1738.813860]   423be718 3d87d50b 3dee8920 3d8850a8
[ 1738.818599]   8217e67b 3df69c00 00000000 3dee8c78
[ 1738.823230]   3df69be0 00000004 00060900 00000000
[ 1738.827901]   8217eb7d 3df69c20 00000cc0 00000000
[ 1738.832585] > 3df69c3c 00000cc0 3df69c50 00000000
[ 1738.837267]   8217ebd9 3df69ca0 00000000 00000009
[ 1738.841946] > 00000000 00000000 00000000 00000000
[ 1738.846643]   3df69c80 3df69c60 0000000c 423be072
[ 1738.851331]   3df69c30 00000000 3d87da8c 00000cc0
[ 1738.856004]   00000cc0 00000000 00000000 00000005
[ 1738.860695]   00000005 00000000 0000001b 00000009
[ 1738.865387]   0000000c 3d87da8c 00000000 3df69c90
[ 1738.870067]   00000001 00000009 00000cc0 00000000
[ 1738.875082]   8217ecec 3df69d20 00000000 00000cc0
[ 1738.879523] > 00000001 00000000 00000000 00000000
[ 1738.884097] Call Trace:
[ 1738.886499]  [<42376e8d>] 0x42376e8d
[ 1738.890083]  [<4217e67b>] 0x4217e67b
[ 1738.893613]  [<4217eb7d>] 0x4217eb7d
[ 1738.897159]  [<4217ebd9>] 0x4217ebd9
[ 1738.900701]  [<4217ecec>] 0x4217ecec
[ 1738.904263]  [<4217ed65>] 0x4217ed65
[ 1738.907818]  [<4217ba6c>] 0x4217ba6c
[ 1738.911377]  [<42176823>] 0x42176823
[ 1738.914940]  [<4217bc5f>] 0x4217bc5f
[ 1738.918530]  [<4217bc7e>] 0x4217bc7e
[ 1738.922061]  [<42120770>] 0x42120770
[ 1738.925611]  [<421204fa>] 0x421204fa
[ 1739.045983] Mem-Info:
[ 1739.046688] active_anon:0 inactive_anon:0 isolated_anon:0
[ 1739.046688]  active_file:0 inactive_file:6 isolated_file:0
[ 1739.046688]  unevictable:24 dirty:0 writeback:0
[ 1739.046688]  slab_reclaimable:173 slab_unreclaimable:805
[ 1739.046688]  mapped:0 shmem:0 pagetables:0
[ 1739.046688]  sec_pagetables:0 bounce:0
[ 1739.046688]  kernel_misc_reclaimable:0
[ 1739.046688]  free:421 free_pcp:0 free_cma:0
[ 1739.135769] Node 0 active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:24kB unevictable:96kB isolated(anon):0kB isolated(file):0kB mapped:0kB dirty:0kB writeback:0kB shmem:0kB writeback_tmp:0kB kernel_stack:320kB pagetables:0kB sec_pagetables:0kB all_unreclaimable? no
[ 1739.183967] Normal free:1680kB boost:0kB min:340kB low:424kB high:508kB reserved_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:24kB unevictable:96kB writepending:0kB present:8192kB managed:7324kB mlocked:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[ 1739.222099] lowmem_reserve[]: 0 0
[ 1739.222938] Normal: 30*4kB (U) 31*8kB (U) 18*16kB (U) 8*32kB (U) 4*64kB (U) 2*128kB (U) 1*256kB (U) 0*512kB 0*1024kB 0*2048kB 0*4096kB = 1680kB
[ 1739.238654] 32 total pagecache pages
[ 1739.239363] 2048 pages RAM
[ 1739.239482] 0 pages HighMem/MovableOnly
[ 1739.239613] 217 pages reserved
[ 1739.241311] nommu: Allocation of length 1052672 from process 214 (micropython) failed
[ 1739.273510] Mem-Info:
[ 1739.274179] active_anon:0 inactive_anon:0 isolated_anon:0
[ 1739.274179]  active_file:0 inactive_file:6 isolated_file:0
[ 1739.274179]  unevictable:24 dirty:0 writeback:0
[ 1739.274179]  slab_reclaimable:173 slab_unreclaimable:805
[ 1739.274179]  mapped:0 shmem:0 pagetables:0
[ 1739.274179]  sec_pagetables:0 bounce:0
[ 1739.274179]  kernel_misc_reclaimable:0
[ 1739.274179]  free:420 free_pcp:0 free_cma:0
[ 1739.353913] Node 0 active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:24kB unevictable:96kB isolated(anon):0kB isolated(file):0kB mapped:0kB dirty:0kB writeback:0kB shmem:0kB writeback_tmp:0kB kernel_stack:320kB pagetables:0kB sec_pagetables:0kB all_unreclaimable? no
[ 1739.383634] Normal free:1680kB boost:0kB min:340kB low:424kB high:508kB reserved_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:24kB unevictable:96kB writepending:0kB present:8192kB managed:7324kB mlocked:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[ 1739.408307] lowmem_reserve[]: 0 0
[ 1739.410645] Normal: 30*4kB (U) 31*8kB (U) 18*16kB (U) 8*32kB (U) 4*64kB (U) 2*128kB (U) 1*256kB (U) 0*512kB 0*1024kB 0*2048kB 0*4096kB = 1680kB
[ 1739.431429] 32 total pagecache pages
[ 1739.432124] 2048 pages RAM
[ 1739.432241] 0 pages HighMem/MovableOnly
[ 1739.433514] 217 pages reserved
Segmentation fault

I build the image with a fork of your buildroot fork (https://github.com/johandevlabs/buildroot/tree/xtensa-2024.05-fdpic_mpy_nc )

@jcmvbkbc
Copy link
Owner

I have also tested micropython, unfortunately it does not work yet
...
[ 1739.241311] nommu: Allocation of length 1052672 from process 214 (micropython) failed

Yeah, there's no way it would succeed on a system with 8M PSRAM.

@johandevlabs
Copy link
Author

Thanks for the hint @jcmvbkbc . I got it to work now (with option -X heapsize=100000)

/etc # micropython -X heapsize=100000
MicroPython v1.22.0 on 2024-09-20; linux [GCC 14.1.0] version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> print("thanks for hint Max! Memory is key")
thanks for hint Max! Memory is key
>>> for i in range(3):
...     print(i)
... 
0
1
2
>>> 
/etc # free -m
              total        used        free      shared  buff/cache   available
Mem:              7           5           2           0           1           1
/etc # free -k
              total        used        free      shared  buff/cache   available
Mem:           7324        4792        1588           0         944        1488

It is amazing that one can run Linux with WiFi and everything on such a small device!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants