mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #15464 from maribu/esp-cast-align
cpu/esp*: Fix cast alignment issues
This commit is contained in:
commit
63af227f01
3
cpu/esp8266/vendor/Makefile
vendored
3
cpu/esp8266/vendor/Makefile
vendored
@ -6,3 +6,6 @@ ifneq (, $(filter esp_gdbstub, $(USEMODULE)))
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
# vendor code contains casts that increase alignment requirements. Let's hope
|
||||
# those are false positives.
|
||||
CFLAGS += -Wno-cast-align
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "architecture.h"
|
||||
#include "board.h"
|
||||
#include "esp_common.h"
|
||||
#include "irq_arch.h"
|
||||
@ -134,10 +135,12 @@ void spi_flash_drive_init (void)
|
||||
|
||||
/* read in partition table an determine the top of all partitions */
|
||||
uint32_t part_addr = ESP_PART_TABLE_ADDR;
|
||||
uint8_t part_buf[ESP_PART_ENTRY_SIZE];
|
||||
uint8_t WORD_ALIGNED part_buf[ESP_PART_ENTRY_SIZE];
|
||||
bool part_read = true;
|
||||
uint32_t part_top = 0;
|
||||
esp_partition_info_t* part = (esp_partition_info_t*)part_buf;
|
||||
/* Use intermediate cast to uintptr_t to silence false positive of
|
||||
* -Wcast-align. We aligned part_buf to word size via attribute */
|
||||
esp_partition_info_t* part = (esp_partition_info_t*)(uintptr_t)part_buf;
|
||||
|
||||
while (part_read && part_addr < ESP_PART_TABLE_ADDR + ESP_PART_TABLE_SIZE) {
|
||||
spi_flash_read (part_addr, (void*)part_buf, ESP_PART_ENTRY_SIZE);
|
||||
@ -436,10 +439,12 @@ const esp_partition_t* esp_partition_find_first(esp_partition_type_t type,
|
||||
const char* label)
|
||||
{
|
||||
uint32_t info_addr = ESP_PART_TABLE_ADDR;
|
||||
uint8_t info_buf[ESP_PART_ENTRY_SIZE];
|
||||
bool info_read = true;
|
||||
uint8_t WORD_ALIGNED info_buf[ESP_PART_ENTRY_SIZE];
|
||||
bool info_read = true;
|
||||
|
||||
esp_partition_info_t* info = (esp_partition_info_t*)info_buf;
|
||||
/* use intermediate cast to uintptr_t to silence false positive of
|
||||
* -Wcast-align. We used an attribute to align info_buf to word boundary */
|
||||
esp_partition_info_t* info = (esp_partition_info_t*)(uintptr_t)info_buf;
|
||||
esp_partition_t* part;
|
||||
|
||||
while (info_read && info_addr < ESP_PART_TABLE_ADDR + ESP_PART_TABLE_SIZE) {
|
||||
|
@ -142,12 +142,12 @@ char* thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_sta
|
||||
uint8_t *top_of_stack;
|
||||
uint8_t *sp;
|
||||
|
||||
top_of_stack = (uint8_t*)((uint32_t)stack_start + stack_size - 1);
|
||||
top_of_stack = (uint8_t*)((uintptr_t)stack_start + stack_size - 1);
|
||||
|
||||
/* BEGIN - code from FreeRTOS port for Xtensa from Cadence */
|
||||
|
||||
/* Create interrupt stack frame aligned to 16 byte boundary */
|
||||
sp = (uint8_t*)(((uint32_t)(top_of_stack + 1) - XT_STK_FRMSZ - XT_CP_SIZE) & ~0xf);
|
||||
sp = (uint8_t*)(((uintptr_t)(top_of_stack + 1) - XT_STK_FRMSZ - XT_CP_SIZE) & ~0xf);
|
||||
|
||||
/* Clear whole stack with a known value to assist debugging */
|
||||
#if !defined(DEVELHELP) && !defined(SCHED_TEST_STACK)
|
||||
@ -160,7 +160,9 @@ char* thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_sta
|
||||
/* ensure that stack is big enough */
|
||||
assert (sp > (uint8_t*)stack_start);
|
||||
|
||||
XtExcFrame* exc_frame = (XtExcFrame*)sp;
|
||||
/* sp is aligned to 16 byte boundary, so cast is safe here. Use an
|
||||
* intermediate cast to uintptr_t to silence -Wcast-align false positive */
|
||||
XtExcFrame* exc_frame = (XtExcFrame*)(uintptr_t)sp;
|
||||
|
||||
/* Explicitly initialize certain saved registers for call0 ABI */
|
||||
exc_frame->pc = (uint32_t)task_func; /* task entry point */
|
||||
@ -344,9 +346,11 @@ void thread_isr_stack_init(void)
|
||||
register uint32_t *sp __asm__ ("a1");
|
||||
#endif /* MCU_ESP32 */
|
||||
|
||||
/* assign each int of the stack the value of it's address */
|
||||
uintptr_t *stackmax = (uintptr_t *)sp;
|
||||
uintptr_t *stackp = (uintptr_t *)&port_IntStack;
|
||||
/* assign each int of the stack the value of it's address. We can safely
|
||||
* cast, as stack is aligned. Use an intermediate cast to uintptr_t to
|
||||
* silence -Wcast-align false positive */
|
||||
uintptr_t *stackmax = (uintptr_t *)(uintptr_t)sp;
|
||||
uintptr_t *stackp = (uintptr_t *)(uintptr_t)&port_IntStack;
|
||||
|
||||
while (stackp < stackmax) {
|
||||
*stackp = (uintptr_t) stackp;
|
||||
|
Loading…
Reference in New Issue
Block a user