gokrazy / tools

this repository contains the gok CLI tool of gokrazy
https://gokrazy.org
BSD 3-Clause "New" or "Revised" License
50 stars 26 forks source link

Copy .dtbo overlays from firmware repo as well #67

Closed Doridian closed 7 months ago

Doridian commented 7 months ago

Paired with https://github.com/gokrazy/firmware/pull/309

stapelberg commented 7 months ago

Thanks for the PR! Unfortunately, something does not seem to be right in the FAT writer (or between the packer and the FAT writer):

% gok -i dr overwrite --boot /tmp/boot.fat
% sudo mount -o loop /tmp/boot.fat /mnt/loop
% ls -l /mnt/loop/overlays 
total 60K
-r-xr-xr-x 1 root root  589 2023-12-13 08:55 act-led.dtbo
-r-xr-xr-x 1 root root 1,6K 2023-12-13 08:55 adafruit18.dtbo
-r-xr-xr-x 1 root root 2,3K 2023-12-13 08:55 adafruit-st7735r.dtbo
-r-xr-xr-x 1 root root 1,1K 2023-12-13 08:55 adau1977-adc.dtbo
-r-xr-xr-x 1 root root 1,6K 2023-12-13 08:55 adau7002-simple.dtbo
-r-xr-xr-x 1 root root 2,5K 2023-12-13 08:55 ads1015.dtbo
-r-xr-xr-x 1 root root 2,5K 2023-12-13 08:55 ads1115.dtbo
-r-xr-xr-x 1 root root 2,4K 2023-12-13 08:55 ads7846.dtbo
-r-xr-xr-x 1 root root 1,8K 2023-12-13 08:55 adv7282m.dtbo
-r-xr-xr-x 1 root root 2,3K 2023-12-13 08:55 adv728x-m.dtbo
-r-xr-xr-x 1 root root 1,4K 2023-12-13 08:55 akkordion-iqdacplus.dtbo
-r-xr-xr-x 1 root root 1,9K 2023-12-13 08:55 allo-boss2-dac-audio.dtbo
-r-xr-xr-x 1 root root 1,7K 2023-12-13 08:55 allo-boss-dac-pcm512x-audio.dtbo
-r-xr-xr-x 1 root root 1,2K 2023-12-13 08:55 allo-digione.dtbo
-r-xr-xr-x 1 root root 1,7K 2023-12-13 08:55 allo-katana-dac-audio.dtbo
-r-xr-xr-x 1 root root 1,0K 2023-12-13 08:55 allo-piano-dac-pcm512x-audio.dtbo
-r-xr-xr-x 1 root root 1,7K 2023-12-13 08:55 allo-piano-dac-plus-pcm512x-audio.dtbo
-r-xr-xr-x 1 root root 3,9K 2023-12-13 08:55 anyspi.dtbo
-r-xr-xr-x 1 root root 1,3K 2023-12-13 08:55 apds9960.dtbo
-r-xr-xr-x 1 root root 1,5K 2023-12-13 08:55 applepi-dac.dtbo
-r-xr-xr-x 1 root root 3,5K 2023-12-13 08:55 arducam-64mp.dtbo
-r-xr-xr-x 1 root root 3,0K 2023-12-13 08:55 arducam-pivariety.dtbo
% 

Only the first 22 overlays are included for some reason? I think we should fix that before merging the PR.

Doridian commented 7 months ago

That is a very odd failure mode. I'll check it out tomorrow if I can see anything wrong.

Doridian commented 7 months ago

@stapelberg I wonder if this is maybe an issue with the FAT16 writer itself? I haven't worked with FAT16 FS internals too much recently. Are we running out of space in the directory entry table or something?

Looking through the FAT file by hand with a hex editor, I can see that directory entries for the "missing" files are produced, but they seem to just not be correctly in the file table they belong...

stapelberg commented 7 months ago

@stapelberg I wonder if this is maybe an issue with the FAT16 writer itself? I haven't worked with FAT16 FS internals too much recently. Are we running out of space in the directory entry table or something?

Yes, I think that’s correct: https://github.com/gokrazy/internal/blob/a645001f8b93c7ebd600649287314b65fb0165b2/fat/writer.go#L554-L559 is hard-coded to one sector.

Let me see if I can fix that real quick.

Update: it’s not that quick a fix. I think we need to change the recursion in writeDir() so that we can write first, then allocate the corresponding fat entries. The problem is that the '..' directory entry in FAT needs to point to the parent directory’s cluster, so we either need to pre-calculate that or fix it afterwards.

stapelberg commented 7 months ago

OK, the large directory issue should be fixed with https://github.com/gokrazy/internal/commit/cb94242910866dd90605ecdf3cda9fa9cd668322