Skip to content

Commit

Permalink
Sector 6 is now protected
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloGonzalezSegarra committed May 18, 2023
1 parent c8b3fe1 commit 9fd0edb
Show file tree
Hide file tree
Showing 21 changed files with 8,852 additions and 8,843 deletions.
1 change: 1 addition & 0 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.1332667918" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.370431092" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.593948302" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.5 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32H723ZGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32H7xx/Include | ../Drivers/STM32H7xx_HAL_Driver/Inc || || || USE_HAL_DRIVER | STM32H723xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32H723ZGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.876002222" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary" value="true" valueType="boolean"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1355170193" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/HUPV-Bootloader}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1343647972" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.2061885926" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
Expand Down
6 changes: 3 additions & 3 deletions Core/App/Bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void const __b_read_memory(fdcan_packet_t* packet){
sector = packet->data[0];
address = flash_get_sector_starting_address(sector);

if (address == FLASH_SECTOR_ERROR || address == FLASH_PROTECTED_SECTOR) {
if (address == FLASH_SECTOR_ERROR || sector >= FLASH_PROTECTED_SECTOR2) {
__b_send_nack(packet);
return;
}
Expand Down Expand Up @@ -138,7 +138,7 @@ void const __b_write_memory(fdcan_packet_t* packet){
sector = packet->data[0];
address = flash_get_sector_starting_address(sector);

if (address == FLASH_SECTOR_ERROR || address == FLASH_PROTECTED_SECTOR) {
if (address == FLASH_SECTOR_ERROR || sector >= FLASH_PROTECTED_SECTOR1) {
__b_send_nack(packet);
return;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ void const __b_erase_memory(fdcan_packet_t* packet){
sector1 = packet->data[0];
sector2 = packet->data[1];

if (sector1 > FLASH_MAX_SECTOR || sector2 > FLASH_MAX_SECTOR) {
if (sector1 > sector2 || sector1 < FLASH_SECTOR_0 || sector2 > FLASH_MAX_SECTOR) {
__b_send_nack(packet);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/App/Bootloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "Flash.h"
#include "FDCAN.h"

#define BOOTLOADER_VERSION (0x04)
#define BOOTLOADER_VERSION (0x05)

#define BOOTLOADER_BLOCK_SIZE ((uint8_t)8U)

Expand Down
2 changes: 1 addition & 1 deletion Core/App/Flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ flash_error const flash_write(uint32_t dest_addr, uint32_t* data, uint32_t numbe
}

flash_error const flash_erase(const sector_t start_sector, const sector_t end_sector){
if (start_sector == FLASH_PROTECTED_SECTOR || end_sector == FLASH_PROTECTED_SECTOR) {
if (start_sector < FLASH_SECTOR_0 || end_sector >= FLASH_PROTECTED_SECTOR1) {
return FLASH_PROTECTED_MEM;
}

Expand Down
8 changes: 4 additions & 4 deletions Core/App/Flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
#define FLASH_START_ADDRESS FLASH_SECTOR0_START_ADDRESS
#define FLASH_END_ADDRESS FLASH_SECTOR7_END_ADDRESS

#define FLASH_CODE_END_ADDRESS FLASH_SECTOR6_END_ADDRESS
#define FLASH_CODE_END_ADDRESS FLASH_SECTOR5_END_ADDRESS

#define FLASH_MAX_SECTOR (FLASH_SECTOR_7 - 1)

#define FLASH_PROTECTED_SECTOR FLASH_SECTOR_7
#define FLASH_PROTECTED_SECTOR1 FLASH_SECTOR_6
#define FLASH_PROTECTED_SECTOR2 FLASH_SECTOR_7

#define FLASH_MAX_SECTOR (FLASH_PROTECTED_SECTOR1 - 1)

/****************************************************************************************
* Type definitions
Expand Down
Binary file modified Debug/Core/App/Bootloader.o
Binary file not shown.
Binary file modified Debug/Core/App/Flash.o
Binary file not shown.
Binary file modified Debug/Core/Src/main.o
Binary file not shown.
Binary file modified Debug/HUPV-Bootloader.bin
Binary file not shown.
Binary file modified Debug/HUPV-Bootloader.elf
Binary file not shown.
Loading

0 comments on commit 9fd0edb

Please sign in to comment.