Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zephyr Firmware
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kestrel Collaboration
Kestrel Firmware
Zephyr Firmware
Commits
9c00187c
Commit
9c00187c
authored
Apr 18, 2021
by
Raptor Engineering Development Team
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial stubs for LFS filesystem support
parent
00e849c2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
1 deletion
+129
-1
CMakeLists.txt
CMakeLists.txt
+1
-0
README.md
README.md
+1
-1
kestrel/src/flash_filesystem.c
kestrel/src/flash_filesystem.c
+105
-0
kestrel/src/flash_filesystem.h
kestrel/src/flash_filesystem.h
+11
-0
kestrel/src/zephyr.c
kestrel/src/zephyr.c
+3
-0
prj.conf
prj.conf
+8
-0
No files found.
CMakeLists.txt
View file @
9c00187c
...
...
@@ -27,6 +27,7 @@ target_sources(app PRIVATE
${
KESTREL_SOURCE_DIR
}
/src/zephyr.c
${
KESTREL_SOURCE_DIR
}
/src/shell.c
${
KESTREL_SOURCE_DIR
}
/src/opencores_i2c.c
${
KESTREL_SOURCE_DIR
}
/src/flash_filesystem.c
${
KESTREL_SOURCE_DIR
}
/src/fsi.c
${
KESTREL_SOURCE_DIR
}
/src/kestrel.c
${
KESTREL_SOURCE_DIR
}
/src/webservice.c
...
...
README.md
View file @
9c00187c
...
...
@@ -28,7 +28,7 @@ How to build:
export SOURCE_ROOT_DIR=$(pwd)
cd zephyr
mkdir build
ZEPHYR_BASE=${SOURCE_ROOT_DIR}/zephyr ZEPHYR_TOOLCHAIN_VARIANT=host cmake -DZEPHYR_MODULES=
${SOURCE_ROOT_DIR}/mbedtls -DZEPHYR_MODULES=${SOURCE_ROOT_DIR}/civetweb
-DBOARD=litex_kestrel ${SOURCE_ROOT_DIR}/zephyr-firmware
ZEPHYR_BASE=${SOURCE_ROOT_DIR}/zephyr ZEPHYR_TOOLCHAIN_VARIANT=host cmake -DZEPHYR_MODULES=
"${SOURCE_ROOT_DIR}/littlefs;${SOURCE_ROOT_DIR}/mbedtls;${SOURCE_ROOT_DIR}/civetweb"
-DBOARD=litex_kestrel ${SOURCE_ROOT_DIR}/zephyr-firmware
cp -Rp ../libsoft-fp.a zephyr/
make -j144
...
...
kestrel/src/flash_filesystem.c
0 → 100644
View file @
9c00187c
// Copyright (c) 2019 Peter Bigot Consulting, LLC
// Copyright (c) 2021 Raptor Engineering, LLC
//
// Released under the terms of the GPL v3
// See the LICENSE file for full details
#include <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 <fs/fs.h>
#include <fs/littlefs.h>
#include <storage/flash_map.h>
#define WITH_ZEPHYR 1
#include "kestrel.h"
// Matches LFS_NAME_MAX */
#define MAX_PATH_LEN 255
#define PARTITION_NODE DT_NODELABEL(lfs1)
#if DT_NODE_EXISTS(PARTITION_NODE)
FS_FSTAB_DECLARE_ENTRY
(
PARTITION_NODE
);
#else
/* PARTITION_NODE */
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
),
.
mnt_point
=
"/lfs"
,
};
#endif
int
initialize_flash_filesystem
(
void
)
{
struct
fs_mount_t
*
mp
=
#if DT_NODE_EXISTS(PARTITION_NODE)
&
FS_FSTAB_ENTRY
(
PARTITION_NODE
)
#else
&
lfs_storage_mnt
#endif
;
unsigned
int
id
=
(
uintptr_t
)
mp
->
storage_dev
;
char
fname
[
MAX_PATH_LEN
];
struct
fs_statvfs
sbuf
;
const
struct
flash_area
*
pfa
;
int
rc
;
snprintf
(
fname
,
sizeof
(
fname
),
"%s/boot_count"
,
mp
->
mnt_point
);
rc
=
flash_area_open
(
id
,
&
pfa
);
if
(
rc
<
0
)
{
printk
(
"FAIL: unable to find flash area %u: %d
\n
"
,
id
,
rc
);
return
;
}
printk
(
"Area %u at 0x%x on %s for %u bytes
\n
"
,
id
,
(
unsigned
int
)
pfa
->
fa_off
,
pfa
->
fa_dev_name
,
(
unsigned
int
)
pfa
->
fa_size
);
/* Optional wipe flash contents */
if
(
IS_ENABLED
(
CONFIG_APP_WIPE_STORAGE
))
{
printk
(
"Erasing flash area ... "
);
rc
=
flash_area_erase
(
pfa
,
0
,
pfa
->
fa_size
);
printk
(
"%d
\n
"
,
rc
);
}
flash_area_close
(
pfa
);
rc
=
fs_mount
(
mp
);
if
(
rc
<
0
)
{
printk
(
"FAIL: mount id %u at %s: %d
\n
"
,
(
unsigned
int
)
mp
->
storage_dev
,
mp
->
mnt_point
,
rc
);
return
;
}
printk
(
"%s mount: %d
\n
"
,
mp
->
mnt_point
,
rc
);
rc
=
fs_statvfs
(
mp
->
mnt_point
,
&
sbuf
);
if
(
rc
<
0
)
{
printk
(
"FAIL: statvfs: %d
\n
"
,
rc
);
goto
fail
;
}
printk
(
"%s: bsize = %lu ; frsize = %lu ;"
" blocks = %lu ; bfree = %lu
\n
"
,
mp
->
mnt_point
,
sbuf
.
f_bsize
,
sbuf
.
f_frsize
,
sbuf
.
f_blocks
,
sbuf
.
f_bfree
);
return
0
;
fail:
rc
=
fs_unmount
(
mp
);
printk
(
"%s unmount: %d
\n
"
,
mp
->
mnt_point
,
rc
);
return
-
1
;
}
\ No newline at end of file
kestrel/src/flash_filesystem.h
0 → 100644
View file @
9c00187c
// © 2021 Raptor Engineering, LLC
//
// Released under the terms of the GPL v3
// See the LICENSE file for full details
#ifndef _FLASH_FILESYSTEM_H
#define _FLASH_FILESYSTEM_H
int
initialize_flash_filesystem
(
void
);
#endif // _FLASH_FILESYSTEM_H
\ No newline at end of file
kestrel/src/zephyr.c
View file @
9c00187c
...
...
@@ -64,6 +64,9 @@ void main(void)
k_sem_init
(
&
kestrel_init_thread_lock
,
0
,
UINT_MAX
);
// Run early setup
initialize_flash_filesystem
();
// Kick off Kestrel initialization thread
kestrel_init_thread_id
=
k_thread_create
(
&
kestrel_init_thread_data
,
kestrel_init_thread_stack
,
K_THREAD_STACK_SIZEOF
(
kestrel_init_thread_stack
),
...
...
prj.conf
View file @
9c00187c
...
...
@@ -18,6 +18,14 @@ CONFIG_SHELL_BACKEND_TELNET=y
CONFIG_THREAD_RUNTIME_STATS
=
y
CONFIG_THREAD_RUNTIME_STATS_USE_TIMING_FUNCTIONS
=
y
# Flash configuration
CONFIG_FLASH
=
y
CONFIG_FLASH_MAP
=
y
CONFIG_FLASH_PAGE_LAYOUT
=
y
CONFIG_FILE_SYSTEM
=
y
CONFIG_FILE_SYSTEM_LITTLEFS
=
y
# Kestrel specific configuration
CONFIG_NET_TC_THREAD_PREEMPTIVE
=
n
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment