Re: Device driver configuration and driver_data distinction.

Marcus Shawcroft <marcus.shawcroft@...>

On 6 October 2016 at 15:58, Andy Ross <andrew.j.ross(a)> wrote:
Marcus Shawcroft wrote (on Thursday, October 06, 2016 3:18AM):
This design make sense from the perspective that the read only config
data *could* be const and placed in flash only, hence lowering
pressure on sram.

However, it is not possible to make a drivers config structure const
because include/device.h defines struct device_config with a non const
Actually it goes into the ROM data section anyway, despite the lack of
const. This is controlled in device.h by declaring the device_config
struct to be in the "devconfig.init" section. This then is placed by
the linker script (one per arhicecture right now, sigh) into the
ROMable region, right before the compiler-managed .rodata (which of
course *is* the stuff that depends on const).

The lack of const is (well, should be) just a missed opportunity for
compiler warnings. But AFAICT it's wrong and should be fixed.
Andy, I think we are talking about to different structures, given:

static struct gpio_k64_config gpio_k64_E_cfg = {
.gpio_base_addr = GPIO_K64_E_BASE_ADDR,
.port_base_addr = PORT_K64_E_BASE_ADDR,
DEVICE_AND_API_INIT(gpio_k64_E, CONFIG_GPIO_K64_E_DEV_NAME, gpio_k64_E_init,
&gpio_data_E, &gpio_k64_E_cfg,

The gpio_k64_E_cfg structure is placed in the data section and copied
to RAM from FLASH at startup.

2000007c l O datas 00000008 gpio_k64_E_cfg

Making in const (and dealing with the *config_info discussed above), gives:
00003b20 l O rodata 00000008 gpio_k64_E_cfg


Join to automatically receive all group messages.