I am wishing to use a SST25VF080B as a bulk flash device in conjunction with the WGM160P module.
We were intending to use SPI0 peripheral, but further reading has led us to believe this may not be possible, and that we have no alternative but to use SPI1 (PB3 MOSI, PB4 MISO, PC4 SCLK). Is this correct?
With regards to setting up the WGM160P to use the bulk flash, I see a couple of variables which need setting:
system.bflash.po rt- this should be set to spi1 (which is the default), correct?
system.bflash.cs_gpio - How is this set? Must the chip select be on the same port as the SPI1 interface data pins (PORT B), or something different? If so, and we are using PB5, does that mean the argument for setting the chip select pin is 5?
Is there anything else I need to consider. I cannot see any way to inform the WGM160P which flash device it is communicating with. Will the WGM160P automatically sense this?
Bulk flash support for Gecko OS is discussed in details here: https://docs.silabs.com/gecko-os/4/standard/latest/filesystem
You will need to set the port (SPI0 or SPI1). This variable is documented here: https://docs.silabs.com/gecko-os/4/standard/latest/cmd/variables/system#system-bflash-port
For the CS, you can use any unused GPIO that you will connect to your flash CS pin. It does not need to be related the the SPI1 pins. More about the CS is here: https://docs.silabs.com/gecko-os/4/standard/latest/cmd/variables/system#system-bflash-cs-gpio
You will need to use the GPIO number, not the port or pad number. The mapping used for Gecko OS is here: https://docs.silabs.com/gecko-os/4/standard/latest/hardware/silabs/wgm160p/wgm160p-wstk-peripherals
Hope that helps.
Thanks for your help so far.
Unfortunately, I still cannot get this working.
I have the following pins assigned:
MOSI - PA0
MISO - PA1
CLK - PA2
Chip Select - PA5
In settings.ini, I have the following variables assigned:
Do I need to call gos_spi_master_init to set up the SPI bus, or is it already set up, as it is used for the on-board extended flash? I have tried initialising it with the following settings, with no success:
const gos_spi_flag_t flags = GOS_SPI_CLOCK_RISING_EDGE | \
GOS_SPI_CLOCK_IDLE_LOW | \
GOS_SPI_MSB_FIRST | \
GOS_SPI_KEEP_ASSERTED | \
GOS_SPI_QUAD_DISABLED | \
GOS_SPI_MASTER_MODE | \
const gos_spi_device_t config =
.port = GOS_SPI_0,
.chip_select = GOS_GPIO_7,
.cs_callback = NULL,
.cs_callback_arg = NULL,
.speed = SPI_SPEED,
.flags = flags,
.bits = SPI_BITS_PER_FRAME,
.lcd_bit8 = FALSE
spi_configured = gos_spi_master_init(&config);
Finally, I try to create a file on the bulk flash, but this fails also:
static gos_file_t record_data_buffer;
static gos_result_t create_data_buffer_file (void)
gos_handle_t handle_ptr = data_buffer_handle;
gos_result_t data_buf_created = 0;
// Initialise the data buffer file
record_data_buffer.handle = data_buffer_handle;
record_data_buffer.type = GOS_FILE_TYPE_GENERAL;
record_data_buffer.location = GOS_FILE_LOCATION_BULK;
record_data_buffer.size_on_flash = DATA_BUFFER_MAX_SIZE_IN_BYTES;
record_data_buffer.permissions = GOS_FILE_PERMISSION_SERIAL_BUS;
// Create the file
if (GOS_FAILED(data_buf_created, gos_file_create(&record_data_buffer, &handle_ptr)))
GOS_LOG("Failed to create energy log file: %d", data_buf_created);
GOS_LOG("Created energy log file");
With the above code I get the following output:
Failed to create energy log file: 7116
Any help with why the above does not work will be very much appreciated. Thanks.
Hi Simon, thanks for opening a new support case (#00220619). Please review David's response on it for more info about the error you've seen.
For others following this thread the summarized response to Simon's last question is:
The error code 7116 from the gos_file_create() function is GOS_FILE_BAD_SIZE. See here: https://docs.silabs.com/gecko-os/4/standard/latest/sdk/group-api-core-types.
The code provided does not set record_data_buffer.size. The documentation for gos_file_create() includes a list of gos_file_t members that are required for creating a file. This documentation also includes a link to a couple examples. See here: https://docs.silabs.com/gecko-os/4/standard/latest/sdk/group-api-file