Simplify partition setup

To prepare part1 for grub, part2 for userdata
This commit is contained in:
Mathieu Maret 2023-11-20 00:15:50 +01:00 committed by Mathieu Maret
parent f05e017d45
commit f110f85498
3 changed files with 6 additions and 7 deletions

View File

@ -65,7 +65,7 @@ disk.img: disk.sfdisk userspace
# Before having filesystem support, just dump the user prog into the first partition
strip userspace/user -o userspace/user.strip
$(eval file_size:=$(shell du -b userspace/user.strip|awk '{print $$1}' | xargs printf "%016d" )) \
sed '1s/^/$(file_size)/' userspace/user.strip | dd of=disk.img seek=2048 bs=512
sed '1s/^/$(file_size)/' userspace/user.strip | dd of=disk.img seek=34816 bs=512
# NASM without preprocessing
%.o:%.asm

View File

@ -45,7 +45,7 @@ void idleThread(void *arg)
#define FILE_MAX_SIZE 64 // In nb of sectors
void loadUserSpace()
{
struct ata_partition *part = ATAGetPartition(0);
struct ata_partition *part = ATAGetPartition(1);
if (part == NULL) {
printf("No user partition found\n");
@ -72,8 +72,8 @@ void loadUserSpace()
sectorToRead = DIV_ROUND_UP(sizeInt, DISK_SECTOR_SIZE) - 1;
}
if (sectorToRead > FILE_MAX_SIZE - 1) {
printf("File too long");
if (sectorToRead > FILE_MAX_SIZE - 1 || sectorToRead <= 0) {
printf("Invalid file size: %d (sector)\n", sectorToRead);
return;
}

View File

@ -4,6 +4,5 @@ device: disk.img
unit: sectors
sector-size: 512
disk.img1 : start= 2048, size= 10240, type=83
disk.img2 : start= 12288, size= 10240, type=b
disk.img3 : start= 22528, size= 43008, type=e
disk.img1 : start= 2048, size= 32768, type=6, bootable
disk.img2 : start= 34816, size= 30720, type=83