Writing image to Slot1 partition causes a hard-fault for firmware update

I'm using VS Code on a Windows 10 machine to develop a product that will use an over the air device firmware update. I have my system setup with static memory partitions. I can get the data to the device, but as soon as I go to write the data to the partition using the functions provided, the system crashes with a hard-fault.

This is my pm_static.yml file:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
app:
address: 0xc200
end_address: 0x44000
region: flash_primary
size: 0x37e00
mcuboot:
address: 0x0
end_address: 0xc000
placement:
before:
- mcuboot_primary
region: flash_primary
size: 0xc000
mcuboot_pad:
address: 0xc000
end_address: 0xc200
placement:
align:
start: 0x1000
before:
- mcuboot_primary_app
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The new partition should be written at 0x00044000.

Using Ozone I was able to see that in the MMFSR I have the flags MMARVALID, MSTKEPP and DACCVIOL set. It looks to me that the memory protection unit is preventing me from writing to flash. I commented out the actual flash write function "flash_img_buffered_write" and that seemed to be the source. After I dug into the code I was able to determin that the offset address for the flash area was set to 0x00000000. That is wrong. So that led me to the "flash_img_init_id" function where it find the context for the flash write. I was using SOC_FLASH_0_ID as the ID (since the definition had the comment "Provided for compatibility with MCUboot"), but I had tried some other things too. The header file does not give much help besides "flash area id of partition where the image should be written". I was not sure how to derive one of these. I tried switching to "flash_img_init" where the function assumes a location to write it to and using "UPLOAD_FLASH_AREA_ID" as the ID. That now gave me the expected address of 0x00044000, but unfortunately I still have the same error s before.

At this point it looks like the using the call "flash_img_buffered_write" should work, but it looks like there is some sort of memory protection there too. Is that assumption correct? I have not found any thing about needing to modify the MPU to do that. I'm not sure if I'm looking in the right place.