Skip to content

Commit 332e04d

Browse files
authored
hotfix(MPU)!: Fix hardfault caused by incorrect linker symbol syntax (#550)
1 parent bd05e1b commit 332e04d

1 file changed

Lines changed: 27 additions & 27 deletions

File tree

Inc/HALAL/Models/MPU.hpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,28 @@
5454
#define RAM_CODE __attribute__((section(".ram_code")))
5555

5656
// Memory Bank Symbols from Linker
57-
extern "C" const uintptr_t __itcm_base;
58-
extern "C" const size_t __itcm_size;
59-
extern "C" const uintptr_t __dtcm_base;
60-
extern "C" const size_t __dtcm_size;
61-
extern "C" const uintptr_t __flash_base;
62-
extern "C" const size_t __flash_size;
63-
extern "C" const uintptr_t __ram_d1_base;
64-
extern "C" const size_t __ram_d1_size;
65-
extern "C" const uintptr_t __ram_d2_base;
66-
extern "C" const size_t __ram_d2_size;
67-
extern "C" const uintptr_t __ram_d3_base;
68-
extern "C" const size_t __ram_d3_size;
69-
extern "C" const uintptr_t __peripheral_base;
70-
extern "C" const size_t __peripheral_size;
57+
extern "C" const char __itcm_base;
58+
extern "C" const char __itcm_size;
59+
extern "C" const char __dtcm_base;
60+
extern "C" const char __dtcm_size;
61+
extern "C" const char __flash_base;
62+
extern "C" const char __flash_size;
63+
extern "C" const char __ram_d1_base;
64+
extern "C" const char __ram_d1_size;
65+
extern "C" const char __ram_d2_base;
66+
extern "C" const char __ram_d2_size;
67+
extern "C" const char __ram_d3_base;
68+
extern "C" const char __ram_d3_size;
69+
extern "C" const char __peripheral_base;
70+
extern "C" const char __peripheral_size;
7171

7272
// MPU Non-Cached Section Symbols from Linker
73-
extern "C" const uintptr_t __mpu_d1_nc_start;
74-
extern "C" const uintptr_t __mpu_d1_nc_end;
75-
extern "C" const uintptr_t __mpu_d2_nc_start;
76-
extern "C" const uintptr_t __mpu_d2_nc_end;
77-
extern "C" const uintptr_t __mpu_d3_nc_start;
78-
extern "C" const uintptr_t __mpu_d3_nc_end;
73+
extern "C" const char __mpu_d1_nc_start;
74+
extern "C" const char __mpu_d1_nc_end;
75+
extern "C" const char __mpu_d2_nc_start;
76+
extern "C" const char __mpu_d2_nc_end;
77+
extern "C" const char __mpu_d3_nc_start;
78+
extern "C" const char __mpu_d3_nc_end;
7979

8080

8181
template <typename T>
@@ -366,42 +366,42 @@ struct MPUDomain {
366366

367367
// Peripherals (Device, Buffered)
368368
// Guarded against speculative execution and cache
369-
configure_region(__peripheral_base, __peripheral_size, MPU_REGION_NUMBER8,
369+
configure_region(reinterpret_cast<uintptr_t>(&__peripheral_base), reinterpret_cast<size_t>(&__peripheral_size), MPU_REGION_NUMBER8,
370370
MPU_TEX_LEVEL0, MPU_REGION_FULL_ACCESS, MPU_INSTRUCTION_ACCESS_DISABLE,
371371
MPU_ACCESS_SHAREABLE, MPU_ACCESS_NOT_CACHEABLE, MPU_ACCESS_BUFFERABLE);
372372

373373
// Flash (Normal, Cacheable)
374374
// TEX=1, C=1, B=0: Normal, Write-Through (Read optimized)
375375
// Not Shareable to allow full caching
376-
configure_region(__flash_base, __flash_size, MPU_REGION_NUMBER1,
376+
configure_region(reinterpret_cast<uintptr_t>(&__flash_base), reinterpret_cast<size_t>(&__flash_size), MPU_REGION_NUMBER1,
377377
MPU_TEX_LEVEL1, MPU_REGION_FULL_ACCESS, MPU_INSTRUCTION_ACCESS_ENABLE,
378378
MPU_ACCESS_NOT_SHAREABLE, MPU_ACCESS_CACHEABLE, MPU_ACCESS_NOT_BUFFERABLE);
379379

380380
// DTCM (Normal, Cacheable)
381381
// Uses Normal memory attributes. TCM access is uncached by hardware, but "Normal" allows unaligned access.
382-
configure_region(__dtcm_base, __dtcm_size, MPU_REGION_NUMBER10,
382+
configure_region(reinterpret_cast<uintptr_t>(&__dtcm_base), reinterpret_cast<size_t>(&__dtcm_size), MPU_REGION_NUMBER10,
383383
MPU_TEX_LEVEL1, MPU_REGION_FULL_ACCESS, MPU_INSTRUCTION_ACCESS_DISABLE,
384384
MPU_ACCESS_NOT_SHAREABLE, MPU_ACCESS_CACHEABLE, MPU_ACCESS_BUFFERABLE);
385385

386386
// ITCM (Normal, Cacheable)
387-
configure_region(__itcm_base, __itcm_size, MPU_REGION_NUMBER11,
387+
configure_region(reinterpret_cast<uintptr_t>(&__itcm_base), reinterpret_cast<size_t>(&__itcm_size), MPU_REGION_NUMBER11,
388388
MPU_TEX_LEVEL1, MPU_REGION_FULL_ACCESS, MPU_INSTRUCTION_ACCESS_ENABLE,
389389
MPU_ACCESS_NOT_SHAREABLE, MPU_ACCESS_CACHEABLE, MPU_ACCESS_BUFFERABLE);
390390

391391
// D1 RAM Cached (Normal, WBWA)
392392
// TEX=1, C=1, B=1: Normal, Write-Back, Write-Allocate
393393
// Not Shareable ensures strict L1 utilization.
394-
configure_region(__ram_d1_base, __ram_d1_size, MPU_REGION_NUMBER2,
394+
configure_region(reinterpret_cast<uintptr_t>(&__ram_d1_base), reinterpret_cast<size_t>(&__ram_d1_size), MPU_REGION_NUMBER2,
395395
MPU_TEX_LEVEL1, MPU_REGION_FULL_ACCESS, MPU_INSTRUCTION_ACCESS_DISABLE,
396396
MPU_ACCESS_NOT_SHAREABLE, MPU_ACCESS_CACHEABLE, MPU_ACCESS_BUFFERABLE);
397397

398398
// D2 RAM Cached (Normal, WBWA)
399-
configure_region(__ram_d2_base, __ram_d2_size, MPU_REGION_NUMBER4,
399+
configure_region(reinterpret_cast<uintptr_t>(&__ram_d2_base), reinterpret_cast<size_t>(&__ram_d2_size), MPU_REGION_NUMBER4,
400400
MPU_TEX_LEVEL1, MPU_REGION_FULL_ACCESS, MPU_INSTRUCTION_ACCESS_DISABLE,
401401
MPU_ACCESS_NOT_SHAREABLE, MPU_ACCESS_CACHEABLE, MPU_ACCESS_BUFFERABLE);
402402

403403
// D3 RAM Cached (Normal, WBWA)
404-
configure_region(__ram_d3_base, __ram_d3_size, MPU_REGION_NUMBER6,
404+
configure_region(reinterpret_cast<uintptr_t>(&__ram_d3_base), reinterpret_cast<size_t>(&__ram_d3_size), MPU_REGION_NUMBER6,
405405
MPU_TEX_LEVEL1, MPU_REGION_FULL_ACCESS, MPU_INSTRUCTION_ACCESS_DISABLE,
406406
MPU_ACCESS_NOT_SHAREABLE, MPU_ACCESS_CACHEABLE, MPU_ACCESS_BUFFERABLE);
407407
}

0 commit comments

Comments
 (0)