Update for Zephyr 3.2.x

NOTE: Mulitple SPI Flash functionality currently broken in Zephyr.
DO NOT USE FOR PRODUCTION
parent ef7415be
/*
* Copyright (c) 2019 Antmicro Ltd
* Copyright (c) 2020 Alexander Kozhinov <AlexanderKozhinov@yandex.com>
* Copyright (c) 2022 Raptor Engineering, LLC <sales@raptorengineering.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(mg_cry_internal_impl, LOG_LEVEL_DBG);
#include "helper.h"
......
/*
* Copyright (c) 2020 Alexander Kozhinov Mail: <AlexanderKozhinov@yandex.com>
* Copyright (c) 2022 Raptor Engineering, LLC <sales@raptorengineering.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
......@@ -7,7 +8,7 @@
#ifndef __HELPER__
#define __HELPER__
#include <logging/log.h>
#include <zephyr/logging/log.h>
#define STR_LOG_ALLOC(str) ((str == NULL) ? log_strdup("null") :\
log_strdup(str))
......
......@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <zephyr/kernel.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <net/socket.h>
#include <zephyr/net/socket.h>
#define pollfd zsock_pollfd
#define fcntl zsock_fcntl
......
/*
* Copyright (c) 2019 Antmicro Ltd
* Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
* Copyright (c) 2021-2022 Raptor Engineering, LLC <sales@raptorengineering.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(lib_extensions, LOG_LEVEL_DBG);
#include <zephyr.h>
#include <zephyr/kernel.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -42,95 +42,6 @@ double difftime(time_t end, time_t beg)
return end - beg;
}
struct __strerr_wrap {
int err;
const char *errstr;
};
/* Implementation suggested by @rakons in #16527 */
#define STRERR_DEFINE(e) {e, #e}
static const struct __strerr_wrap error_strings[] = {
STRERR_DEFINE(EILSEQ),
STRERR_DEFINE(EDOM),
STRERR_DEFINE(ERANGE),
STRERR_DEFINE(ENOTTY),
STRERR_DEFINE(EACCES),
STRERR_DEFINE(EPERM),
STRERR_DEFINE(ENOENT),
STRERR_DEFINE(ESRCH),
STRERR_DEFINE(EEXIST),
STRERR_DEFINE(ENOSPC),
STRERR_DEFINE(ENOMEM),
STRERR_DEFINE(EBUSY),
STRERR_DEFINE(EINTR),
STRERR_DEFINE(EAGAIN),
STRERR_DEFINE(ESPIPE),
STRERR_DEFINE(EXDEV),
STRERR_DEFINE(EROFS),
STRERR_DEFINE(ENOTEMPTY),
STRERR_DEFINE(ECONNRESET),
STRERR_DEFINE(ETIMEDOUT),
STRERR_DEFINE(ECONNREFUSED),
STRERR_DEFINE(EHOSTDOWN),
STRERR_DEFINE(EHOSTUNREACH),
STRERR_DEFINE(EADDRINUSE),
STRERR_DEFINE(EPIPE),
STRERR_DEFINE(EIO),
STRERR_DEFINE(ENXIO),
STRERR_DEFINE(ENOTBLK),
STRERR_DEFINE(ENODEV),
STRERR_DEFINE(ENOTDIR),
STRERR_DEFINE(EISDIR),
STRERR_DEFINE(ETXTBSY),
STRERR_DEFINE(ENOEXEC),
STRERR_DEFINE(EINVAL),
STRERR_DEFINE(E2BIG),
STRERR_DEFINE(ELOOP),
STRERR_DEFINE(ENAMETOOLONG),
STRERR_DEFINE(ENFILE),
STRERR_DEFINE(EMFILE),
STRERR_DEFINE(EBADF),
STRERR_DEFINE(ECHILD),
STRERR_DEFINE(EFAULT),
STRERR_DEFINE(EFBIG),
STRERR_DEFINE(EMLINK),
STRERR_DEFINE(ENOLCK),
STRERR_DEFINE(EDEADLK),
STRERR_DEFINE(ECANCELED),
STRERR_DEFINE(ENOSYS),
STRERR_DEFINE(ENOMSG),
STRERR_DEFINE(ENOSTR),
STRERR_DEFINE(ENODATA),
STRERR_DEFINE(ETIME),
STRERR_DEFINE(ENOSR),
STRERR_DEFINE(EPROTO),
STRERR_DEFINE(EBADMSG),
STRERR_DEFINE(ENOTSOCK),
STRERR_DEFINE(EDESTADDRREQ),
STRERR_DEFINE(EMSGSIZE),
STRERR_DEFINE(EPROTOTYPE),
STRERR_DEFINE(ENOPROTOOPT),
STRERR_DEFINE(EPROTONOSUPPORT),
STRERR_DEFINE(ESOCKTNOSUPPORT),
STRERR_DEFINE(ENOTSUP),
STRERR_DEFINE(EPFNOSUPPORT),
STRERR_DEFINE(EAFNOSUPPORT),
STRERR_DEFINE(EADDRNOTAVAIL),
STRERR_DEFINE(ENETDOWN),
STRERR_DEFINE(ENETUNREACH),
STRERR_DEFINE(ENETRESET),
STRERR_DEFINE(ECONNABORTED),
STRERR_DEFINE(ENOBUFS),
STRERR_DEFINE(EISCONN),
STRERR_DEFINE(ENOTCONN),
STRERR_DEFINE(ESHUTDOWN),
STRERR_DEFINE(EALREADY),
STRERR_DEFINE(EINPROGRESS),
};
static char *strerr_unknown = "UNKNOWN";
int fileno(FILE *stream)
{
FN_MISSING();
......@@ -145,19 +56,6 @@ int ferror(FILE *stream)
return 0;
}
char *strerror(int err)
{
int i;
for (i = 0; i < ARRAY_SIZE(error_strings); ++i) {
if (error_strings[i].err == err) {
return (char *)error_strings[i].errstr;
}
}
return strerr_unknown;
}
int sscanf(const char *s, const char *format, ...)
{
FN_MISSING();
......
......@@ -22,8 +22,8 @@
*/
#include <stdint.h>
#include <zephyr.h>
#include <posix/pthread.h>
#include <zephyr/kernel.h>
#include <zephyr/posix/pthread.h>
#include "libc_extensions.h"
#include "civetweb.h"
......@@ -290,4 +290,4 @@ void civetweb_send_file(struct mg_connection *conn, const char* content_type, co
if (!is_head_request) {
civetweb_send_file_data(conn, data + r1, cl, use_chunked_encoding);
}
}
\ No newline at end of file
}
// Copyright (c) 2019 Peter Bigot Consulting, LLC
// Copyright (c) 2021 Raptor Engineering, LLC
// Copyright (c) 2021-2022 Raptor Engineering, LLC
//
// Released under the terms of the GPL v3
// See the LICENSE file for full details
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(flash_filesystem, LOG_LEVEL_DBG);
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <zephyr.h>
#include <device.h>
#include <sys/crc.h>
#include <fs/fs.h>
#include <fs/littlefs.h>
#include <drivers/flash.h>
#include <storage/flash_map.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/sys/crc.h>
#include <zephyr/fs/fs.h>
#include <zephyr/fs/littlefs.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/storage/flash_map.h>
#define WITH_ZEPHYR 1
......@@ -39,7 +39,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
static struct fs_mount_t lfs_storage_mnt = {
.type = FS_LITTLEFS,
.fs_data = &storage,
.storage_dev = (void *)FLASH_AREA_ID(storage),
.storage_dev = (void *)FIXED_PARTITION_ID(zephyr_rwfs),
.mnt_point = "/lfs",
};
#endif
......@@ -69,7 +69,7 @@ int initialize_flash_filesystem(void)
}
printk("Area %u at 0x%x on %s for %u bytes\n",
id, (unsigned int)pfa->fa_off, pfa->fa_dev_name,
id, (unsigned int)pfa->fa_off, pfa->fa_dev->name,
(unsigned int)pfa->fa_size);
/* Optional wipe flash contents */
......@@ -119,7 +119,7 @@ int write_firmware_to_flash(const char* device_name, int partition_number, const
// Find BMC firmware Flash map area
flash_area = NULL;
for (int i = 0; i < flash_map_entries; i++) {
if (strcmp(flash_map[i].fa_dev_name, device_name) == 0) {
if (strcmp(flash_map[i].fa_dev->name, device_name) == 0) {
if (flash_map[i].fa_id == partition_number) {
flash_area = &flash_map[i];
break;
......
......@@ -3,7 +3,7 @@
// Released under the terms of the LGPL v3+
// See the LICENSE file for full details
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(kestrel_fsi, LOG_LEVEL_DBG);
#include "fsi.h"
......
......@@ -7,17 +7,17 @@
#define WITH_ZEPHYR 1
#if (WITH_ZEPHYR)
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(kestrel_core, LOG_LEVEL_DBG);
#endif
#include "fsi.h"
#include "utility.h"
#include <sys/crc.h>
#include <zephyr/sys/crc.h>
#include <generated/csr.h>
#include <generated/mem.h>
#include <irq.h>
#include <zephyr/irq.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -4,7 +4,7 @@
// See the LICENSE file for full details
#if (WITH_ZEPHYR)
#include <shell/shell.h>
#include <zephyr/shell/shell.h>
#endif
#if (WITH_ZEPHYR)
......
......@@ -3,7 +3,7 @@
// Released under the terms of the LGPL v3+
// See the LICENSE file for full details
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(onewire_core, LOG_LEVEL_DBG);
#include "onewire_functions.h"
......
......@@ -3,7 +3,7 @@
// Released under the terms of the LGPL v3+
// See the LICENSE file for full details
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(kestrel_onewire, LOG_LEVEL_DBG);
#include "opencores_1wire.h"
......@@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(kestrel_onewire, LOG_LEVEL_DBG);
int initialize_onewire_master(uint8_t *base_address)
{
KESTREL_LOG("Configuring 1-wire master at address %p...", base_address);
KESTREL_LOG("Configuring 1-wire master at address %p...", (void*)base_address);
if ((*((volatile uint32_t *)(base_address + OPENCORES_1WIRE_MASTER_DEVICE_ID_HIGH)) != OPENCORES_1WIRE_DEVICE_ID_HIGH) ||
(*((volatile uint32_t *)(base_address + OPENCORES_1WIRE_MASTER_DEVICE_ID_LOW)) != OPENCORES_1WIRE_DEVICE_ID_LOW))
......@@ -224,4 +224,4 @@ int transfer_onewire_data_block(uint8_t *base_address, uint8_t enable_overdrive,
}
return onewire_op_failed;
}
\ No newline at end of file
}
......@@ -3,7 +3,7 @@
// Released under the terms of the LGPL v3+
// See the LICENSE file for full details
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(kestrel_i2c, LOG_LEVEL_DBG);
#include "opencores_i2c.h"
......@@ -20,18 +20,18 @@ LOG_MODULE_REGISTER(kestrel_i2c, LOG_LEVEL_DBG);
int initialize_i2c_master(uint8_t *base_address, int i2c_bus_frequency)
{
KESTREL_LOG("Configuring I2C master at address %p...", base_address);
KESTREL_LOG("Configuring I2C master at address %p...", (void*)base_address);
if ((*((volatile uint32_t *)(base_address + OPENCORES_I2C_MASTER_DEVICE_ID_HIGH)) != OPENCORES_I2C_DEVICE_ID_HIGH) ||
(*((volatile uint32_t *)(base_address + OPENCORES_I2C_MASTER_DEVICE_ID_LOW)) != OPENCORES_I2C_DEVICE_ID_LOW))
{
return -1;
}
uint32_t opencores_spi_version = *((volatile uint32_t *)(base_address + OPENCORES_I2C_MASTER_DEVICE_VERSION));
uint32_t opencores_i2c_version = *((volatile uint32_t *)(base_address + OPENCORES_I2C_MASTER_DEVICE_VERSION));
KESTREL_LOG("OpenCores I2C master found, device version %0d.%0d.%d",
(opencores_spi_version >> OPENCORES_I2C_VERSION_MAJOR_SHIFT) & OPENCORES_I2C_VERSION_MAJOR_MASK,
(opencores_spi_version >> OPENCORES_I2C_VERSION_MINOR_SHIFT) & OPENCORES_I2C_VERSION_MINOR_MASK,
(opencores_spi_version >> OPENCORES_I2C_VERSION_PATCH_SHIFT) & OPENCORES_I2C_VERSION_PATCH_MASK);
(opencores_i2c_version >> OPENCORES_I2C_VERSION_MAJOR_SHIFT) & OPENCORES_I2C_VERSION_MAJOR_MASK,
(opencores_i2c_version >> OPENCORES_I2C_VERSION_MINOR_SHIFT) & OPENCORES_I2C_VERSION_MINOR_MASK,
(opencores_i2c_version >> OPENCORES_I2C_VERSION_PATCH_SHIFT) & OPENCORES_I2C_VERSION_PATCH_MASK);
// Compute prescale value from system clock and desired I2C frequency in HZ
uint16_t i2c_prescale = (CONFIG_CLOCK_FREQUENCY / (5LL * i2c_bus_frequency)) - 1;
......@@ -271,4 +271,4 @@ int i2c_write_register_byte(uint8_t *base_address, uint8_t slave_address, uint8_
}
return 1;
}
\ No newline at end of file
}
......@@ -4,12 +4,12 @@
* SPDX-License-Identifier: GPL-3.0
*/
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(redfish, LOG_LEVEL_DBG);
#include <zephyr.h>
#include <posix/pthread.h>
#include <data/json.h>
#include <zephyr/kernel.h>
#include <zephyr/posix/pthread.h>
#include <zephyr/data/json.h>
#include "simple_pwm.h"
......
......@@ -3,13 +3,13 @@
// Released under the terms of the LGPL v3+
// See the LICENSE file for full details
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(kestrel_sbe_fsi, LOG_LEVEL_DBG);
#include <sys/byteorder.h>
#include <zephyr/sys/byteorder.h>
#include <stdlib.h>
#include <errno.h>
#include <zephyr.h>
#include <zephyr/kernel.h>
#include "fsi.h"
#include "sbe_fsi.h"
......
......@@ -6,8 +6,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <shell/shell.h>
#include <drivers/uart.h>
#include <zephyr/shell/shell.h>
#include <zephyr/drivers/uart.h>
#include <generated/csr.h>
#define WITH_ZEPHYR 1
......
......@@ -3,7 +3,7 @@
// Released under the terms of the LGPL v3+
// See the LICENSE file for full details
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(kestrel_pwm, LOG_LEVEL_DBG);
#include "simple_pwm.h"
......@@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(kestrel_pwm, LOG_LEVEL_DBG);
int initialize_pwm_controller(uint8_t *base_address)
{
KESTREL_LOG("Configuring PWM controller at address %p...", base_address);
KESTREL_LOG("Configuring PWM controller at address %p...", (void*)base_address);
if ((*((volatile uint32_t *)(base_address + SIMPLE_PWM_MASTER_DEVICE_ID_HIGH)) != SIMPLE_PWM_DEVICE_ID_HIGH) ||
(*((volatile uint32_t *)(base_address + SIMPLE_PWM_MASTER_DEVICE_ID_LOW)) != SIMPLE_PWM_DEVICE_ID_LOW))
......
......@@ -4,12 +4,12 @@
* SPDX-License-Identifier: GPL-3.0
*/
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(webportal, LOG_LEVEL_DBG);
#include <zephyr.h>
#include <posix/pthread.h>
#include <data/json.h>
#include <zephyr/kernel.h>
#include <zephyr/posix/pthread.h>
#include <zephyr/data/json.h>
#include "simple_pwm.h"
#include "sbe_fsi.h"
......
......@@ -5,9 +5,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <posix/pthread.h>
#include <data/json.h>
#include <zephyr/kernel.h>
#include <zephyr/posix/pthread.h>
#include <zephyr/data/json.h>
#include "webportal.h"
......
......@@ -3,16 +3,16 @@
// Released under the terms of the GPL v3
// See the LICENSE file for full details
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(kestrel_init, LOG_LEVEL_DBG);
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <zephyr.h>
#include <device.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <generated/mem.h>
#include <drivers/gpio.h>
#include <zephyr/drivers/gpio.h>
#define WITH_ZEPHYR 1
......
......@@ -25,6 +25,7 @@ CONFIG_THREAD_RUNTIME_STATS_USE_TIMING_FUNCTIONS=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_JESD216_API=y
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment