Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv: Fix build warning #2860

Merged
merged 1 commit into from
Aug 4, 2022
Merged

Conversation

kasjer
Copy link
Contributor

@kasjer kasjer commented Aug 3, 2022

This eliminates following warning:

/tmp/ccfBOXIv.s: Assembler messages:
/tmp/ccfBOXIv.s:6: Warning: setting incorrect section attributes for .data.fe310_flash_transmit
/tmp/ccfBOXIv.s:41: Warning: setting incorrect section attributes for .data.fe310_flash_fifo_put
/tmp/ccfBOXIv.s:89: Warning: setting incorrect section attributes for .data.fe310_flash_fifo_write
/tmp/ccfBOXIv.s:145: Warning: setting incorrect section attributes for .data.fe310_flash_wait_till_ready
/tmp/ccfBOXIv.s:194: Warning: setting incorrect section attributes for .data.fe310_flash_write_enable
/tmp/ccfBOXIv.s:232: Warning: setting incorrect section attributes for .data.fe310_flash_write_page
/tmp/ccfBOXIv.s:419: Warning: setting incorrect section attributes for .data.fe310_flash_erase_sector

.data.XXXX section gets default attributes that are no executable
renaming .data to .ram_text fixes assembler warning
This requries change to linker script that now has to include .ram_text.XXXXX in data section
to work as it used to before change

This eliminates following warning:

/tmp/ccfBOXIv.s: Assembler messages:
/tmp/ccfBOXIv.s:6: Warning: setting incorrect section attributes for .data.fe310_flash_transmit
/tmp/ccfBOXIv.s:41: Warning: setting incorrect section attributes for .data.fe310_flash_fifo_put
/tmp/ccfBOXIv.s:89: Warning: setting incorrect section attributes for .data.fe310_flash_fifo_write
/tmp/ccfBOXIv.s:145: Warning: setting incorrect section attributes for .data.fe310_flash_wait_till_ready
/tmp/ccfBOXIv.s:194: Warning: setting incorrect section attributes for .data.fe310_flash_write_enable
/tmp/ccfBOXIv.s:232: Warning: setting incorrect section attributes for .data.fe310_flash_write_page
/tmp/ccfBOXIv.s:419: Warning: setting incorrect section attributes for .data.fe310_flash_erase_sector

.data.XXXX section gets default attributes that are no executable
renaming .data to .ram_text fixes assembler warning
This requries change to linker script that now has to include .ram_text.XXXXX in data section
to work as it used to before change
Copy link
Contributor

@mlaz mlaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good

@apache-mynewt-bot
Copy link

Style check summary

Our coding style is here!

hw/mcu/sifive/fe310/src/hal_flash.c

@@ -64,15 +64,15 @@
 
 static int
 fe310_flash_read(const struct hal_flash *dev, uint32_t address, void *dst,
-        uint32_t num_bytes)
+                 uint32_t num_bytes)
 {
     memcpy(dst, (void *)address, num_bytes);
     return 0;
 }
 
-static int __attribute((section(".ram_text.fe310_flash_transmit")))
-fe310_flash_transmit(uint8_t out_byte)
-{
+static int
+__attribute((section(".ram_text.fe310_flash_transmit")))
+fe310_flash_transmit(uint8_t out_byte) {
     int in_byte;
 
     /* Empty RX FIFO */
@@ -80,15 +80,15 @@
     }
     SPI0_REG(SPI_REG_TXFIFO) = out_byte;
     do {
-         in_byte = SPI0_REG(SPI_REG_RXFIFO);
+        in_byte = SPI0_REG(SPI_REG_RXFIFO);
     } while (in_byte < 0);
 
     return in_byte;
 }
 
-static int __attribute((section(".ram_text.fe310_flash_fifo_put")))
-fe310_flash_fifo_put(uint8_t out_byte)
-{
+static int
+__attribute((section(".ram_text.fe310_flash_fifo_put")))
+fe310_flash_fifo_put(uint8_t out_byte) {
     int went_out = 0;
 
     /* Empty RX FIFO */
@@ -105,9 +105,9 @@
     return went_out;
 }
 
-static int __attribute((section(".ram_text.fe310_flash_fifo_write")))
-fe310_flash_fifo_write(const uint8_t *ptr, int count)
-{
+static int
+__attribute((section(".ram_text.fe310_flash_fifo_write")))
+fe310_flash_fifo_write(const uint8_t *ptr, int count) {
     int went_out = 0;
 
     while (count > 0) {
@@ -123,9 +123,9 @@
     return went_out;
 }
 
-static int __attribute((section(".ram_text.fe310_flash_wait_till_ready")))
-fe310_flash_wait_till_ready(void)
-{
+static int
+__attribute((section(".ram_text.fe310_flash_wait_till_ready")))
+fe310_flash_wait_till_ready(void) {
     int status;
     do {
         SPI0_REG(SPI_REG_CSMODE) = SPI_CSMODE_HOLD;
@@ -138,19 +138,19 @@
     return 0;
 }
 
-static int __attribute((section(".ram_text.fe310_flash_write_enable")))
-fe310_flash_write_enable(void)
-{
+static int
+__attribute((section(".ram_text.fe310_flash_write_enable")))
+fe310_flash_write_enable(void) {
     SPI0_REG(SPI_REG_CSMODE) = SPI_CSMODE_HOLD;
     fe310_flash_transmit(FLASH_CMD_WRITE_ENABLE);
     SPI0_REG(SPI_REG_CSMODE) = SPI_CSMODE_AUTO;
     return 0;
 }
 
-static int  __attribute((section(".ram_text.fe310_flash_write_page"))) __attribute((noinline))
+static int
+__attribute((section(".ram_text.fe310_flash_write_page"))) __attribute((noinline))
 fe310_flash_write_page(const struct hal_flash *dev, uint32_t address,
-                      const void *src, uint32_t num_bytes)
-{
+                      const void *src, uint32_t num_bytes) {
     int sr;
     /* Number of bytes that left controller FIFO */
     int went_out = 0;
@@ -232,9 +232,9 @@
     return 0;
 }
 
-static int __attribute((section(".ram_text.fe310_flash_erase_sector"))) __attribute((noinline))
-fe310_flash_erase_sector(const struct hal_flash *dev, uint32_t sector_address)
-{
+static int
+__attribute((section(".ram_text.fe310_flash_erase_sector"))) __attribute((noinline))
+fe310_flash_erase_sector(const struct hal_flash *dev, uint32_t sector_address) {
     int sr;
     __HAL_DISABLE_INTERRUPTS(sr);
 

@kasjer kasjer merged commit 8262452 into apache:master Aug 4, 2022
@kasjer kasjer deleted the kasjer/fe310-fix-asm-warning branch August 4, 2022 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants