[target][zybo] add sysparam and ptable support
Add some code in target init that sets up the spi flash ptable and sysparam block.
This commit is contained in:
@@ -7,7 +7,12 @@ MODULES += \
|
||||
app/stringtests \
|
||||
app/shell \
|
||||
lib/cksum \
|
||||
lib/debugcommands
|
||||
lib/sysparam \
|
||||
lib/debugcommands \
|
||||
lib/ptable \
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
SYSPARAM_ALLOW_WRITE=1
|
||||
|
||||
include $(LOCAL_DIR)/zybo.mk
|
||||
|
||||
|
||||
@@ -20,7 +20,10 @@
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <dev/spiflash.h>
|
||||
#include <lib/ptable.h>
|
||||
#include <lib/sysparam.h>
|
||||
|
||||
void target_early_init(void)
|
||||
{
|
||||
@@ -30,5 +33,40 @@ void target_init(void)
|
||||
{
|
||||
/* zybo has a spiflash on qspi */
|
||||
spiflash_detect();
|
||||
|
||||
bdev_t *spi = bio_open("spi0");
|
||||
|
||||
#if WITH_LIB_PTABLE && WITH_LIB_SYSPARAM
|
||||
if (spi) {
|
||||
/* find or create a partition table at the start of flash */
|
||||
if (ptable_scan(spi, 0) < 0) {
|
||||
ptable_create_default(spi, 0);
|
||||
}
|
||||
|
||||
struct ptable_entry entry = { 0 };
|
||||
|
||||
if (ptable_find("sysparam", &entry) < 0) {
|
||||
/* didn't find sysparam partition, create it */
|
||||
ptable_add("sysparam", 0x1000, 0x1000, 0);
|
||||
ptable_find("sysparam", &entry);
|
||||
}
|
||||
|
||||
printf("flash partition table:\n");
|
||||
ptable_dump();
|
||||
|
||||
if (entry.length > 0) {
|
||||
sysparam_scan(spi, entry.offset, entry.length);
|
||||
|
||||
#if SYSPARAM_ALLOW_WRITE
|
||||
/* for testing purposes, put at least one sysparam value in */
|
||||
if (sysparam_add("dummy", "value", sizeof("value")) >= 0) {
|
||||
sysparam_write();
|
||||
}
|
||||
#endif
|
||||
|
||||
sysparam_dump(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user