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

Simulator fixes and support for using MacOS #334

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ include/target.h
.bootloader-partition-size

# Test tools
tools/check_config/check_config
tools/test-expect-version/test-expect-version
tools/test-update-server/server
tools/uart-flash-server/ufserver
Expand Down
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ $(PRIVATE_KEY):
$(Q)(test $(SIGN) = NONE) && (echo "// SIGN=NONE" > src/keystore.c) || true

keytools:
@echo "Building key tools"
@$(MAKE) -C tools/keytools -s clean
@$(MAKE) -C tools/keytools
@$(MAKE) -C tools/keytools -j

test-app/image_v1_signed.bin: $(BOOT_IMG)
@echo "\t[SIGN] $(BOOT_IMG)"
Expand All @@ -175,12 +176,14 @@ test-app/image.elf: wolfboot.elf
$(Q)$(MAKE) -C test-app WOLFBOOT_ROOT="$(WOLFBOOT_ROOT)" image.elf
$(Q)$(SIZE) test-app/image.elf

internal_flash.dd: $(BINASSEMBLE) wolfboot.elf test-app/image_v1_signed.bin
internal_flash.dd: $(BINASSEMBLE) wolfboot.bin $(BOOT_IMG) $(PRIVATE_KEY) test-app/image_v1_signed.bin
@echo "\t[MERGE] internal_flash.dd"
$(Q)dd if=/dev/zero bs=1 count=$$(($(WOLFBOOT_SECTOR_SIZE))) > /tmp/swap
$(Q)$(BINASSEMBLE) $@ 0 test-app/image_v1_signed.bin \
$(WOLFBOOT_PARTITION_SIZE) /tmp/swap \
$$(($(WOLFBOOT_PARTITION_SIZE)*2)) /tmp/swap
$(Q)$(BINASSEMBLE) $@ \
0 wolfboot.bin \
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) test-app/image_v1_signed.bin \
$$(($(WOLFBOOT_PARTITION_UPDATE_ADDRESS)-$(ARCH_FLASH_OFFSET))) /tmp/swap \
$$(($(WOLFBOOT_PARTITION_SWAP_ADDRESS)-$(ARCH_FLASH_OFFSET))) /tmp/swap

factory.bin: $(BINASSEMBLE) wolfboot.bin $(BOOT_IMG) $(PRIVATE_KEY) test-app/image_v1_signed.bin
@echo "\t[MERGE] $@"
Expand Down
3 changes: 1 addition & 2 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ ifeq ($(USE_GCC),1)
CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)gcc
AS=$(CROSS_COMPILE)gcc
OBJCOPY=$(CROSS_COMPILE)objcopy
OBJCOPY?=$(CROSS_COMPILE)objcopy
SIZE=$(CROSS_COMPILE)size
OUTPUT_FLAG=-o
endif
Expand Down Expand Up @@ -569,7 +569,6 @@ ifeq ($(TARGET),x86_64_efi)
endif

ifeq ($(TARGET),sim)
ARCH_FLASH_OFFSET=0xC0000000
USE_GCC_HEADLESS=0
LD = gcc
UPDATE_OBJS:=src/update_flash.o
Expand Down
10 changes: 6 additions & 4 deletions config/examples/sim-delta-update.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ WOLFBOOT_SMALL_STACK=1
SPI_FLASH=0
DEBUG=1
DELTA_UPDATES=1
# it should be multiple of system page size

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0xC0020000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
# if on external flash, it should be multiple of system page size
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0xC0060000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xC00A0000
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x60000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xA0000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1
10 changes: 6 additions & 4 deletions config/examples/sim-ecc.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ HASH?=SHA256
WOLFBOOT_SMALL_STACK=1
SPI_FLASH=0
DEBUG=1
# it should be multiple of system page size

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0xC0020000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
# if on external flash, it should be multiple of system page size
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0xC0060000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xC00A0000
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x60000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xA0000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1
6 changes: 4 additions & 2 deletions config/examples/sim-encrypt-delta-update.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ ENCRYPT=1
ENCRYPT_WITH_AES128=1
DEBUG=1
DELTA_UPDATES=1
# it should be multiple of system page size

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0xC0020000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
# if on external flash, it should be multiple of system page size
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x00000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x40000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1
6 changes: 4 additions & 2 deletions config/examples/sim-encrypt-update.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ EXT_FLASH=1
ENCRYPT=1
ENCRYPT_WITH_AES128=1
DEBUG=1
# it should be multiple of system page size

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0xC0020000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
# if on external flash, it should be multiple of system page size
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x00000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x40000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1
10 changes: 6 additions & 4 deletions config/examples/sim-nvm-writeonce.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ HASH?=SHA256
WOLFBOOT_SMALL_STACK=1
SPI_FLASH=0
DEBUG=1
# it should be multiple of system page size
NVM_FLASH_WRITEONCE=1

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0xC0020000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
# if on external flash, it should be multiple of system page size
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0xC0060000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xC00A0000
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x60000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xA0000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1
10 changes: 6 additions & 4 deletions config/examples/sim-rsa.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ WOLFBOOT_SMALL_STACK=1
SPI_FLASH=0
DEBUG=1
SPMATHALL=1
# it should be multiple of system page size

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0xC0020000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
# if on external flash, it should be multiple of system page size
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0xC0060000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xC00A0000
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x60000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xA0000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1
23 changes: 23 additions & 0 deletions config/examples/sim-tpm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARCH=sim
TARGET=sim
SIGN?=RSA2048
HASH?=SHA256
WOLFBOOT_SMALL_STACK=1
SPI_FLASH=0
DEBUG=1
SIM_TPM=1
WOLFTPM=1

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80000
# if on external flash, it should be multiple of system page size
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x100000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x180000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1

# TPM Logging
# CFLAGS_EXTRA+=-DDEBUG_WOLFTPM -DWOLFTPM_DEBUG_VERBOSE
10 changes: 6 additions & 4 deletions config/examples/sim.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ HASH?=SHA256
WOLFBOOT_SMALL_STACK=1
SPI_FLASH=0
DEBUG=1
# it should be multiple of system page size

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0xC0020000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
# if on external flash, it should be multiple of system page size
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0xC0060000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xC00A0000
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x60000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xA0000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1
2 changes: 2 additions & 0 deletions docs/Targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,8 @@ make test-sim-internal-flash-with-update
./wolfboot.elf success get_version
```

Note: This also works on Mac OS, but `objcopy` does not exist. Install with `brew install binutils` and make using `OBJCOPY=/usr/local/Cellar//binutils/2.41/bin/objcopy make`.


## Renesas RX72N

Expand Down
4 changes: 2 additions & 2 deletions hal/raspi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void hal_prepare_boot(void)
}


int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
int RAMFUNCTION hal_flash_write(uintptr_t address, const uint8_t *data, int len)
{
return 0;
}
Expand All @@ -128,7 +128,7 @@ void RAMFUNCTION hal_flash_lock(void)
}


int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
int RAMFUNCTION hal_flash_erase(uintptr_t address, int len)
{
return 0;
}
Loading
Loading