Add build steps to adjust CRC for QSPI file

This is lifted from the WP43 project.
The idea is to be able to move "heavy" and rarely moving data, like fonts, into
the QSPI, so that we have more room for the main program in Flash.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
Christophe de Dinechin 2023-06-21 08:29:59 +02:00
parent e835e38781
commit b9f5803fa8
4 changed files with 19 additions and 48 deletions

View file

@ -30,6 +30,10 @@ TOOLS = tools
# CRC adjustment
CRCFIX = $(TOOLS)/forcecrc32/forcecrc32
FLASH=$(BUILD)/$(TARGET)_flash.bin
QSPI =$(BUILD)/$(TARGET)_qspi.bin
#==============================================================================
#
@ -240,10 +244,11 @@ $(BUILD)/%.o: %.s Makefile | $(BUILD)
$(BUILD)/$(TARGET).elf: $(OBJECTS) Makefile
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(TARGET).pgm: $(BUILD)/$(TARGET).elf Makefile $(CRCFIX)
$(OBJCOPY) --remove-section .qspi -O ihex $< $(BUILD)/$(TARGET)_flash.hex
$(OBJCOPY) --remove-section .qspi -O binary $< $(BUILD)/$(TARGET)_flash.bin
$(OBJCOPY) --only-section .qspi -O ihex $< $(BUILD)/$(TARGET)_qspi.hex
$(OBJCOPY) --only-section .qspi -O binary $< $(BUILD)/$(TARGET)_qspi.bin
$(OBJCOPY) --remove-section .qspi -O binary $< $(FLASH)
$(OBJCOPY) --remove-section .qspi -O ihex $< $(FLASH:.bin=.hex)
$(OBJCOPY) --only-section .qspi -O binary $< $(QSPI)
$(OBJCOPY) --only-section .qspi -O ihex $< $(QSPI:.bin=.hex)
$(TOOLS)/adjust_crc $(CRCFIX) $(QSPI)
$(TOOLS)/check_qspi_crc $(TARGET) $(BUILD)/$(TARGET)_qspi.bin src/qspi_crc.h || ( $(MAKE) clean && false )
$(TOOLS)/add_pgm_chsum $(BUILD)/$(TARGET)_flash.bin $@
$(SIZE) $<

View file

@ -1,46 +1,4 @@
/*
BSD 3-Clause License
Copyright (c) 2015-2022, SwissMicros
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The software and related material is released as NOMAS (NOt MAnufacturer Supported).
1. Info is released to assist customers using, exploring and extending the product
2. Do NOT contact the manufacturer with questions, seeking support, etc. regarding
NOMAS material as no support is implied or committed-to by the Manufacturer
3. The Manufacturer may reply and/or update materials if and when needed solely
at their discretion
*/
#define QSPI_DATA_SIZE 1370864
#define QSPI_DATA_SIZE 1370868
#define QSPI_DATA_CRC 0x000cfed6

8
tools/adjust_crc Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
crcfix="$1"
qspi="$2"
sz=$(cat $qspi | wc -c)
echo -n -e '\x00\x00\x00\x00' >> $qspi
$crcfix $qspi $sz 000CFED6

View file

@ -59,7 +59,7 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
char temp[21] = {0};
sprintf(temp, "%" PRIu64, offset);
snprintf(temp, sizeof(temp), "%" PRIu64, offset);
if (strcmp(temp, argv[2]) != 0) {
fprintf(stderr, "Error: Invalid byte offset\n");
return EXIT_FAILURE;