Compare commits
3 Commits
main
...
bazel_supp
| Author | SHA1 | Date | |
|---|---|---|---|
| e907023423 | |||
| 09f0382e56 | |||
| 80f454d546 |
1269
BUILD.bazel
Normal file
1269
BUILD.bazel
Normal file
File diff suppressed because it is too large
Load Diff
4
MODULE.bazel
Normal file
4
MODULE.bazel
Normal file
@ -0,0 +1,4 @@
|
||||
module(
|
||||
name = "esp_open_rtos",
|
||||
version = "0.1",
|
||||
)
|
||||
133
bazel/cc_static_library.bzl
Normal file
133
bazel/cc_static_library.bzl
Normal file
@ -0,0 +1,133 @@
|
||||
"""Provides a rule that outputs a monolithic static library."""
|
||||
|
||||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
|
||||
|
||||
TOOLS_CPP_REPO = "@bazel_tools"
|
||||
|
||||
def _cc_static_library_impl(ctx):
|
||||
output_lib = ctx.actions.declare_file("{}.a".format(ctx.attr.name))
|
||||
output_flags = ctx.actions.declare_file("{}.link".format(ctx.attr.name))
|
||||
|
||||
cc_toolchain = find_cpp_toolchain(ctx)
|
||||
|
||||
# Populate the feature configuration. This is used by the various cc library
|
||||
# functions to generate contexts.
|
||||
feature_configuration = cc_common.configure_features(
|
||||
ctx = ctx,
|
||||
cc_toolchain = cc_toolchain,
|
||||
requested_features = ctx.features,
|
||||
unsupported_features = ctx.disabled_features
|
||||
)
|
||||
|
||||
lib_sets = []
|
||||
lib_inputs = []
|
||||
unique_flags = {}
|
||||
|
||||
merged_compilation_context = cc_common.merge_compilation_contexts(
|
||||
compilation_contexts = [dep[CcInfo].compilation_context for dep in ctx.attr.deps]
|
||||
)
|
||||
|
||||
for dep in ctx.attr.deps:
|
||||
if hasattr(dep[CcInfo].linking_context.linker_inputs, "to_list"):
|
||||
lib_inputs.append(dep[CcInfo].linking_context.linker_inputs.to_list())
|
||||
else:
|
||||
lib_inputs.append(dep[CcInfo].linking_context.linker_inputs)
|
||||
|
||||
for lib in dep[CcInfo].linking_context.linker_inputs.to_list():
|
||||
if hasattr(lib.libraries, "to_list"):
|
||||
lib_sets.append(lib.libraries)
|
||||
else:
|
||||
lib_sets.append(depset(direct = lib.libraries))
|
||||
unique_flags.update({
|
||||
flag: None
|
||||
for flag in lib.user_link_flags
|
||||
})
|
||||
|
||||
libraries_to_link = depset(transitive = lib_sets)
|
||||
link_flags = unique_flags.keys()
|
||||
|
||||
libs = []
|
||||
libs.extend([lib.pic_static_library for lib in libraries_to_link.to_list() if lib.pic_static_library])
|
||||
libs.extend([
|
||||
lib.static_library
|
||||
for lib in libraries_to_link.to_list()
|
||||
if lib.static_library and not lib.pic_static_library
|
||||
])
|
||||
|
||||
script_file = ctx.actions.declare_file("{}.mri".format(ctx.attr.name))
|
||||
commands = ["create {}".format(output_lib.path)]
|
||||
for lib in libs:
|
||||
commands.append("addlib {}".format(lib.path))
|
||||
commands.append("save")
|
||||
commands.append("end")
|
||||
ctx.actions.write(
|
||||
output = script_file,
|
||||
content = "\n".join(commands) + "\n",
|
||||
)
|
||||
|
||||
ar_tool = cc_common.get_tool_for_action(
|
||||
feature_configuration = feature_configuration,
|
||||
action_name = "ar",
|
||||
)
|
||||
|
||||
ctx.actions.run_shell(
|
||||
command = "{} -M < {}".format(ar_tool, script_file.path),
|
||||
inputs = [script_file] + libs + cc_toolchain.all_files.to_list(),
|
||||
outputs = [output_lib],
|
||||
mnemonic = "ArMerge",
|
||||
progress_message = "Merging static library {}".format(output_lib.path),
|
||||
)
|
||||
ctx.actions.write(
|
||||
output = output_flags,
|
||||
content = "\n".join(link_flags) + "\n",
|
||||
)
|
||||
|
||||
# With the library in hand, the next step is to set up information for
|
||||
# Bazel's C/C++ library to utilize the newly-created library.
|
||||
library_to_link = cc_common.create_library_to_link(
|
||||
actions = ctx.actions,
|
||||
feature_configuration = feature_configuration,
|
||||
static_library = output_lib,
|
||||
#user_link_flags = ['fooxbar']
|
||||
)
|
||||
|
||||
linker_input = cc_common.create_linker_input(
|
||||
libraries = depset([library_to_link]),
|
||||
owner = ctx.label,
|
||||
)
|
||||
|
||||
linking_context = cc_common.create_linking_context(
|
||||
linker_inputs = depset([linker_input])
|
||||
)
|
||||
|
||||
# CcInfo is what is actually passed to future targets. We may need to merge
|
||||
# this with the dependency's original info in order for builds to complete.
|
||||
# Not sure yet.
|
||||
this_cc_info = CcInfo(compilation_context = merged_compilation_context, linking_context = linking_context)
|
||||
cc_infos = [this_cc_info]
|
||||
# print(this_cc_info.linking_context)
|
||||
# print(ctx.attr.library[CcInfo].compilation_context)
|
||||
# print(ctx.attr.library[CcInfo].linking_context)
|
||||
# cc_infos.append(ctx.attr.library[CcInfo])
|
||||
|
||||
merged_cc_info = cc_common.merge_cc_infos(direct_cc_infos = [this_cc_info], cc_infos = cc_infos)
|
||||
# print(merged_cc_info.linking_context)
|
||||
|
||||
return [
|
||||
DefaultInfo(files = depset([output_lib])),
|
||||
merged_cc_info
|
||||
]
|
||||
|
||||
cc_static_library = rule(
|
||||
implementation = _cc_static_library_impl,
|
||||
attrs = {
|
||||
"deps": attr.label_list(),
|
||||
"_cc_toolchain": attr.label(
|
||||
default = TOOLS_CPP_REPO + "//tools/cpp:current_cc_toolchain",
|
||||
),
|
||||
},
|
||||
toolchains = [TOOLS_CPP_REPO + "//tools/cpp:toolchain_type"],
|
||||
fragments = ["cpp"],
|
||||
incompatible_use_toolchain_transition = True,
|
||||
)
|
||||
|
||||
73
bazel/postprocess_archive.sh
Executable file
73
bazel/postprocess_archive.sh
Executable file
@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This wrapper script takes a given archive (static library) and processes it,
|
||||
# either removing/renaming symbols according to the provided arguments.
|
||||
|
||||
BAZEL_EXECROOT=
|
||||
ARCHIVE_TOOL=
|
||||
OBJCOPY_TOOL=
|
||||
INPUT_FILE=
|
||||
OUTPUT_FILE=
|
||||
STAGE_NUMBER=0
|
||||
|
||||
RENAME_FILE=
|
||||
|
||||
ARGS=()
|
||||
|
||||
set -e
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--archive)
|
||||
ARCHIVE_TOOL="$2"
|
||||
shift; shift; ;;
|
||||
--objcopy)
|
||||
OBJCOPY_TOOL="$2"
|
||||
shift; shift; ;;
|
||||
--input)
|
||||
INPUT_FILE="$2"
|
||||
shift; shift; ;;
|
||||
--output)
|
||||
OUTPUT_FILE="$2"
|
||||
shift; shift; ;;
|
||||
--remove|--redefine)
|
||||
ARGS+=("$1")
|
||||
shift ; ;;
|
||||
-*)
|
||||
echo "Unknown option $1"
|
||||
exit 1 ; ;;
|
||||
*)
|
||||
ARGS+=("$1")
|
||||
shift ; ;;
|
||||
esac
|
||||
done
|
||||
|
||||
set -- "${ARGS[@]}"
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "No modification to be performed."
|
||||
exit 2;
|
||||
fi
|
||||
|
||||
IN=${INPUT_FILE}
|
||||
while [[ $# -gt 0 ]]; do
|
||||
OUT=${OUTPUT_FILE}.stage${STAGE_NUMBER}
|
||||
case $1 in
|
||||
--remove)
|
||||
# Avoid read-only input file.
|
||||
cat $IN > $OUT && $ARCHIVE_TOOL d $OUT @$2
|
||||
|
||||
shift; shift; ;;
|
||||
--redefine)
|
||||
$OBJCOPY_TOOL --redefine-syms $2 --weaken $IN $OUT
|
||||
shift; shift; ;;
|
||||
*)
|
||||
echo "Bad argument: $1"
|
||||
exit 3 ; ;;
|
||||
esac
|
||||
STAGE_NUMBER=$((STAGE_NUMBER+1))
|
||||
IN=$OUT
|
||||
done
|
||||
|
||||
|
||||
mv $IN $OUTPUT_FILE
|
||||
149
bazel/postprocess_static_library.bzl
Normal file
149
bazel/postprocess_static_library.bzl
Normal file
@ -0,0 +1,149 @@
|
||||
# postprocess_static_library takes a prebuilt archive (static library) and
|
||||
# filters out unnecessary objects / redefines symbols files.
|
||||
# In ESP8266's case, this is because the ROM already provides their
|
||||
# implementations.
|
||||
|
||||
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
|
||||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl",
|
||||
"find_cpp_toolchain", "use_cpp_toolchain")
|
||||
|
||||
def _impl(ctx):
|
||||
# Find the toolchain configuration for the given platform. This is _not_
|
||||
# the same way that other languages do this, as ctx.toolchains is empty
|
||||
# for C/C++ (??)
|
||||
cc_toolchain = find_cpp_toolchain(ctx)
|
||||
|
||||
# Populate the feature configuration. This is used by the various cc library
|
||||
# functions to generate contexts.
|
||||
feature_configuration = cc_common.configure_features(
|
||||
ctx = ctx,
|
||||
cc_toolchain = cc_toolchain,
|
||||
requested_features = ctx.features,
|
||||
unsupported_features = ctx.disabled_features
|
||||
)
|
||||
|
||||
# We need these toolchain executables in order to process the library.
|
||||
archive_tool = cc_common.get_tool_for_action(
|
||||
feature_configuration = feature_configuration,
|
||||
action_name = ACTION_NAMES.cpp_link_static_library,
|
||||
)
|
||||
|
||||
objcopy_tool = cc_common.get_tool_for_action(
|
||||
feature_configuration = feature_configuration,
|
||||
action_name = "objcopy"
|
||||
)
|
||||
|
||||
# Library label (target) for processing.
|
||||
input_lib = ctx.file.library
|
||||
|
||||
# The output library will be named after the target of this rule.
|
||||
output_lib = ctx.actions.declare_file(ctx.label.name + ".a")
|
||||
|
||||
# Bazel needs to know what files are inputs to a given action.
|
||||
input_files = [input_lib]
|
||||
|
||||
# Construct the argument list to pass to the postprocessor script
|
||||
args = ctx.actions.args()
|
||||
args.add_all([
|
||||
'--input', input_lib,
|
||||
'--output', output_lib,
|
||||
'--archive', archive_tool,
|
||||
'--objcopy', objcopy_tool
|
||||
])
|
||||
|
||||
# If removing objects from the library, create a file, write the objects
|
||||
# to remove into it, and add it to the list of inputs for the action.
|
||||
if len(ctx.attr.remove) > 0:
|
||||
rmobjs = ctx.actions.declare_file(ctx.file.library.basename + ".remove")
|
||||
ctx.actions.write(rmobjs, "\n".join(ctx.attr.remove))
|
||||
input_files.append(rmobjs)
|
||||
args.add_all(['--remove', rmobjs])
|
||||
|
||||
# Similar for redefining symbols.
|
||||
if len(ctx.attr.redefine) > 0:
|
||||
rdobjs = ctx.actions.declare_file(ctx.file.library.basename + ".redefine")
|
||||
kv_pairs = [k + " " + v for k, v in ctx.attr.redefine.items()]
|
||||
ctx.actions.write(rdobjs, "\n".join(kv_pairs) + "\n")
|
||||
input_files.append(rdobjs)
|
||||
args.add_all(['--redefine', rdobjs])
|
||||
|
||||
# TODO: Handle other ways to process a library.
|
||||
|
||||
# This runs the actual script to generate the processed library.
|
||||
ctx.actions.run(
|
||||
inputs = input_files,
|
||||
outputs = [output_lib],
|
||||
tools = cc_toolchain.all_files,
|
||||
arguments = [args],
|
||||
executable = ctx.executable.postprocessor,
|
||||
)
|
||||
|
||||
# With the library in hand, the next step is to set up information for
|
||||
# Bazel's C/C++ library to utilize the newly-created library.
|
||||
library_to_link = cc_common.create_library_to_link(
|
||||
actions = ctx.actions,
|
||||
feature_configuration = feature_configuration,
|
||||
static_library = output_lib,
|
||||
)
|
||||
|
||||
linker_input = cc_common.create_linker_input(
|
||||
libraries = depset([library_to_link]),
|
||||
owner = ctx.label,
|
||||
)
|
||||
|
||||
linking_context = cc_common.create_linking_context(
|
||||
linker_inputs = depset([linker_input])
|
||||
)
|
||||
|
||||
# Not yet complete: This part needs us to forward the library and its
|
||||
# associated headers for targets to use without forwarding the original
|
||||
# target's library (or you'll get a bunch of linking errors.
|
||||
(compilation_context, compilation_outputs) = cc_common.compile(
|
||||
actions = ctx.actions,
|
||||
feature_configuration = feature_configuration,
|
||||
cc_toolchain = cc_toolchain,
|
||||
name = ctx.label.name,
|
||||
)
|
||||
|
||||
# CcInfo is what is actually passed to future targets. We may need to merge
|
||||
# this with the dependency's original info in order for builds to complete.
|
||||
# Not sure yet.
|
||||
this_cc_info = CcInfo(compilation_context = compilation_context, linking_context = linking_context)
|
||||
cc_infos = [this_cc_info]
|
||||
# print(this_cc_info.linking_context)
|
||||
# print(ctx.attr.library[CcInfo].compilation_context)
|
||||
# print(ctx.attr.library[CcInfo].linking_context)
|
||||
# cc_infos.append(ctx.attr.library[CcInfo])
|
||||
|
||||
merged_cc_info = cc_common.merge_cc_infos(direct_cc_infos = [this_cc_info], cc_infos = cc_infos)
|
||||
# print(merged_cc_info.linking_context)
|
||||
|
||||
return [
|
||||
DefaultInfo(files = depset([output_lib])),
|
||||
merged_cc_info
|
||||
]
|
||||
|
||||
postprocess_static_library = rule(
|
||||
implementation = _impl,
|
||||
attrs = {
|
||||
"library": attr.label(
|
||||
allow_single_file = True,
|
||||
),
|
||||
"remove": attr.string_list(
|
||||
doc = "A list of modules (objects) to remove from the library.",
|
||||
),
|
||||
"redefine": attr.string_dict(
|
||||
doc = "A list of symbols to redefine in the library.",
|
||||
),
|
||||
"postprocessor": attr.label(
|
||||
default = Label("//toolchain:postprocess_archive"),
|
||||
executable = True,
|
||||
cfg = "exec",
|
||||
),
|
||||
"_cc_toolchain": attr.label(
|
||||
default = "@bazel_tools//tools/cpp:current_cc_toolchain",
|
||||
)
|
||||
},
|
||||
fragments = ["cpp"],
|
||||
toolchains = use_cpp_toolchain(),
|
||||
)
|
||||
@ -115,6 +115,7 @@ $(1)_CPPFLAGS ?= $(CPPFLAGS)
|
||||
$(1)_CFLAGS ?= $(CFLAGS)
|
||||
$(1)_CXXFLAGS ?= $(CXXFLAGS)
|
||||
$(1)_CC_BASE = $(Q) $(CC) $$(addprefix -I,$$(INC_DIRS)) $$(addprefix -I,$$($(1)_INC_DIR)) $$($(1)_CPPFLAGS)
|
||||
$(1)_CXX_BASE = $(Q) $(C++) $$(addprefix -I,$$(INC_DIRS)) $$(addprefix -I,$$($(1)_INC_DIR)) $$($(1)_CPPFLAGS)
|
||||
$(1)_AR = $(call lc,$(BUILD_DIR)$(1).a)
|
||||
|
||||
$$($(1)_OBJ_DIR)%.o: $$($(1)_REAL_ROOT)%.c $$($(1)_MAKEFILE) $(wildcard $(ROOT)*.mk) | $$($(1)_SRC_DIR)
|
||||
@ -126,8 +127,8 @@ $$($(1)_OBJ_DIR)%.o: $$($(1)_REAL_ROOT)%.c $$($(1)_MAKEFILE) $(wildcard $(ROOT)*
|
||||
$$($(1)_OBJ_DIR)%.o: $$($(1)_REAL_ROOT)%.cpp $$($(1)_MAKEFILE) $(wildcard $(ROOT)*.mk) | $$($(1)_SRC_DIR)
|
||||
$(vecho) "C++ $$<"
|
||||
$(Q) mkdir -p $$(dir $$@)
|
||||
$$($(1)_CC_BASE) $$($(1)_CXXFLAGS) -c $$< -o $$@
|
||||
$$($(1)_CC_BASE) $$($(1)_CXXFLAGS) -MM -MT $$@ -MF $$(@:.o=.d) $$<
|
||||
$$($(1)_CXX_BASE) $$($(1)_CXXFLAGS) -c $$< -o $$@
|
||||
$$($(1)_CXX_BASE) $$($(1)_CXXFLAGS) -MM -MT $$@ -MF $$(@:.o=.d) $$<
|
||||
|
||||
$$($(1)_OBJ_DIR)%.o: $$($(1)_REAL_ROOT)%.S $$($(1)_MAKEFILE) $(wildcard $(ROOT)*.mk) | $$($(1)_SRC_DIR)
|
||||
$(vecho) "AS $$<"
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
const static uint32_t IROM _TIMER_FREQS[] = { _FREQ_DIV1, _FREQ_DIV16, _FREQ_DIV256 };
|
||||
|
||||
/* Timer divisor index to divisor value */
|
||||
const static uint32_t IROM _TIMER_DIV_VAL[] = { 1, 16, 256 };
|
||||
const static uint32_t IROM _TIMER_DIV_VAL[] __attribute__((unused)) = { 1, 16, 256 };
|
||||
|
||||
void timer_set_interrupts(const timer_frc_t frc, bool enable)
|
||||
{
|
||||
|
||||
@ -39,11 +39,29 @@
|
||||
|
||||
/* Set bits in reg with specified mask.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
constexpr inline auto SET_MASK_BITS(auto volatile& reg, auto mask) {
|
||||
auto value = reg;
|
||||
value |= mask;
|
||||
reg = value;
|
||||
return reg;
|
||||
}
|
||||
#else
|
||||
#define SET_MASK_BITS(reg, mask) (reg) |= (mask)
|
||||
#endif
|
||||
|
||||
/* Clear bits in reg with specified mask
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
constexpr inline auto CLEAR_MASK_BITS(auto volatile& reg, auto mask) {
|
||||
auto value = reg;
|
||||
value &= ~mask;
|
||||
reg = value;
|
||||
return reg;
|
||||
}
|
||||
#else
|
||||
#define CLEAR_MASK_BITS(reg, mask) (reg) &= ~(mask)
|
||||
#endif
|
||||
|
||||
/* Use the IRAM macro to place functions into Instruction RAM (IRAM)
|
||||
instead of flash (aka irom).
|
||||
|
||||
@ -21,7 +21,7 @@ void dump_heapinfo(void);
|
||||
Probably not useful to be called in other contexts.
|
||||
*/
|
||||
void __attribute__((noreturn)) fatal_exception_handler(uint32_t *sp, bool registers_saved_on_stack);
|
||||
void __attribute__((weak, alias("fatal_exception_handler")))
|
||||
void __attribute__((noreturn)) __attribute__((weak, alias("fatal_exception_handler")))
|
||||
debug_exception_handler(uint32_t *sp, bool registers_saved_on_stack);
|
||||
|
||||
#endif
|
||||
|
||||
@ -48,7 +48,13 @@ void gpio_set_pullup(uint8_t gpio_num, bool enabled, bool enabled_during_sleep);
|
||||
static inline void gpio_disable(const uint8_t gpio_num)
|
||||
{
|
||||
GPIO.ENABLE_OUT_CLEAR = BIT(gpio_num);
|
||||
#ifdef __cplusplus
|
||||
auto value = *gpio_iomux_reg(gpio_num);
|
||||
value &= ~IOMUX_PIN_OUTPUT_ENABLE;
|
||||
*gpio_iomux_reg(gpio_num) = value;
|
||||
#else
|
||||
*gpio_iomux_reg(gpio_num) &= ~IOMUX_PIN_OUTPUT_ENABLE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Set whether the specified pin continues to drive its output when the ESP8266
|
||||
@ -61,9 +67,21 @@ static inline void gpio_disable(const uint8_t gpio_num)
|
||||
static inline void gpio_set_output_on_sleep(const uint8_t gpio_num, bool enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
#ifdef __cplusplus
|
||||
auto value = IOMUX.PIN[gpio_to_iomux(gpio_num)];
|
||||
value |= IOMUX_PIN_OUTPUT_ENABLE_SLEEP;
|
||||
IOMUX.PIN[gpio_to_iomux(gpio_num)] = value;
|
||||
#else
|
||||
IOMUX.PIN[gpio_to_iomux(gpio_num)] |= IOMUX_PIN_OUTPUT_ENABLE_SLEEP;
|
||||
#endif
|
||||
} else {
|
||||
#ifdef __cplusplus
|
||||
auto value = IOMUX.PIN[gpio_to_iomux(gpio_num)];
|
||||
value &= ~IOMUX_PIN_OUTPUT_ENABLE_SLEEP;
|
||||
IOMUX.PIN[gpio_to_iomux(gpio_num)] = value;
|
||||
#else
|
||||
IOMUX.PIN[gpio_to_iomux(gpio_num)] &= ~IOMUX_PIN_OUTPUT_ENABLE_SLEEP;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -65,10 +65,23 @@ void timer_set_interrupts(const timer_frc_t frc, bool enable);
|
||||
/* Turn the timer on or off */
|
||||
static inline void timer_set_run(const timer_frc_t frc, const bool run)
|
||||
{
|
||||
if (run)
|
||||
if (run) {
|
||||
#ifdef __cplusplus
|
||||
auto value = TIMER(frc).CTRL;
|
||||
value |= TIMER_CTRL_RUN;
|
||||
TIMER(frc).CTRL = value;
|
||||
#else
|
||||
TIMER(frc).CTRL |= TIMER_CTRL_RUN;
|
||||
else
|
||||
#endif
|
||||
} else {
|
||||
#ifdef __cplusplus
|
||||
auto value = TIMER(frc).CTRL;
|
||||
value &= ~TIMER_CTRL_RUN;
|
||||
TIMER(frc).CTRL = value;
|
||||
#else
|
||||
TIMER(frc).CTRL &= ~TIMER_CTRL_RUN;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the run state of the timer (on or off) */
|
||||
@ -80,10 +93,23 @@ static inline bool timer_get_run(const timer_frc_t frc)
|
||||
/* Set timer auto-reload on or off */
|
||||
static inline void timer_set_reload(const timer_frc_t frc, const bool reload)
|
||||
{
|
||||
if (reload)
|
||||
if (reload) {
|
||||
#ifdef __cplusplus
|
||||
auto value = TIMER(frc).CTRL;
|
||||
value |= TIMER_CTRL_RELOAD;
|
||||
TIMER(frc).CTRL = value;
|
||||
#else
|
||||
TIMER(frc).CTRL |= TIMER_CTRL_RELOAD;
|
||||
else
|
||||
#endif
|
||||
} else {
|
||||
#ifdef __cplusplus
|
||||
auto value = TIMER(frc).CTRL;
|
||||
value &= ~TIMER_CTRL_RELOAD;
|
||||
TIMER(frc).CTRL = value;
|
||||
#else
|
||||
TIMER(frc).CTRL &= ~TIMER_CTRL_RELOAD;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the auto-reload state of the timer (on or off) */
|
||||
|
||||
@ -29,6 +29,11 @@
|
||||
#if LWIP_SOCKET_OFFSET < 3
|
||||
#error Expecting a LWIP_SOCKET_OFFSET >= 3, to allow room for the standard I/O descriptors.
|
||||
#endif
|
||||
|
||||
extern ssize_t lwip_read(int s, void *mem, size_t len);
|
||||
extern ssize_t lwip_write(int s, const void *mem, size_t len);
|
||||
extern int lwip_close(int s);
|
||||
|
||||
#define FILE_DESCRIPTOR_OFFSET (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN)
|
||||
#if FILE_DESCRIPTOR_OFFSET > FD_SETSIZE
|
||||
#error Too many lwip sockets for the FD_SETSIZE.
|
||||
@ -175,31 +180,6 @@ __attribute__((weak)) int _close_r(struct _reent *r, int fd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Stub syscall implementations follow, to allow compiling newlib functions that
|
||||
pull these in via various codepaths
|
||||
*/
|
||||
__attribute__((weak, alias("syscall_returns_enosys")))
|
||||
int _open_r(struct _reent *r, const char *pathname, int flags, int mode);
|
||||
|
||||
__attribute__((weak, alias("syscall_returns_enosys")))
|
||||
int _unlink_r(struct _reent *r, const char *path);
|
||||
|
||||
__attribute__((weak, alias("syscall_returns_enosys")))
|
||||
int _fstat_r(struct _reent *r, int fd, struct stat *buf);
|
||||
|
||||
__attribute__((weak, alias("syscall_returns_enosys")))
|
||||
int _stat_r(struct _reent *r, const char *pathname, struct stat *buf);
|
||||
|
||||
__attribute__((weak, alias("syscall_returns_enosys")))
|
||||
off_t _lseek_r(struct _reent *r, int fd, off_t offset, int whence);
|
||||
|
||||
__attribute__((weak, alias("_gettimeofday_r")))
|
||||
int _gettimeofday_r (struct _reent *ptr, struct timeval *ptimeval, void *ptimezone) {
|
||||
ptimeval->tv_sec = 0;
|
||||
ptimeval->tv_usec = 0;
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Generic stub for any newlib syscall that fails with errno ENOSYS
|
||||
("Function not implemented") and a return value equivalent to
|
||||
@ -209,6 +189,31 @@ static int syscall_returns_enosys(struct _reent *r)
|
||||
r->_errno=ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
/* Stub syscall implementations follow, to allow compiling newlib functions that
|
||||
pull these in via various codepaths
|
||||
*/
|
||||
__attribute__((weak))
|
||||
int _open_r(struct _reent *r, const char *pathname, int flags, int mode) { return syscall_returns_enosys(r); }
|
||||
|
||||
__attribute__((weak))
|
||||
int _unlink_r(struct _reent *r, const char *path) { return syscall_returns_enosys(r); }
|
||||
|
||||
__attribute__((weak))
|
||||
int _fstat_r(struct _reent *r, int fd, struct stat *buf) { return syscall_returns_enosys(r); }
|
||||
|
||||
__attribute__((weak))
|
||||
int _stat_r(struct _reent *r, const char *pathname, struct stat *buf) { return syscall_returns_enosys(r); }
|
||||
|
||||
__attribute__((weak))
|
||||
off_t _lseek_r(struct _reent *r, int fd, off_t offset, int whence) { return syscall_returns_enosys(r); }
|
||||
|
||||
__attribute__((weak))
|
||||
int _gettimeofday_r (struct _reent *ptr, struct timeval *ptimeval, void *ptimezone) {
|
||||
ptimeval->tv_sec = 0;
|
||||
ptimeval->tv_usec = 0;
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int getentropy(void *ptr, size_t n)
|
||||
{
|
||||
|
||||
@ -174,8 +174,13 @@
|
||||
/* Run full RF CAL routine. RF init takes approx 200ms. */
|
||||
#define RF_CAL_MODE_FULL 3
|
||||
|
||||
/* Data structure that maps to the phy_info configuration block */
|
||||
typedef struct __attribute__((packed)) {
|
||||
/* Data structure that maps to the phy_info configuration block.
|
||||
* This was originally attributed with the ((packed)) attribute,
|
||||
* but I don't currently see a reason why it needs to be. The
|
||||
* structure uses only u8, so there shouldn't be any padding
|
||||
* inserted.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t _reserved00[0x05]; /* 0x00 - 0x04 */
|
||||
|
||||
/* This "version" field was set to 5 in the SDK phy_info,
|
||||
|
||||
@ -144,8 +144,12 @@ void qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t _compar);
|
||||
int rand (void);
|
||||
void * realloc (void *__r, size_t __size) _NOTHROW;
|
||||
#if __BSD_VISIBLE
|
||||
#if 0
|
||||
void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
|
||||
__alloc_size(3);
|
||||
#else
|
||||
void *reallocarray(void *, size_t, size_t) __result_use_check __attribute__((alloc_size(2, 3)));
|
||||
#endif
|
||||
void * reallocf (void *__r, size_t __size);
|
||||
#endif
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
|
||||
|
||||
@ -404,7 +404,7 @@ struct _reent
|
||||
char *_asctime_buf;
|
||||
|
||||
/* signal info */
|
||||
void (**(_sig_func))(int);
|
||||
void (**_sig_func)(int);
|
||||
|
||||
# ifndef _REENT_GLOBAL_ATEXIT
|
||||
/* atexit stuff */
|
||||
|
||||
@ -6,7 +6,7 @@ INC_DIRS += $(LWIP_DIR)include $(ROOT)lwip/include $(lwip_ROOT)include $(LWIP_DI
|
||||
# args for passing into compile rule generation
|
||||
lwip_INC_DIR = # all in INC_DIRS, needed for normal operation
|
||||
lwip_SRC_DIR = $(lwip_ROOT) $(LWIP_DIR)api $(LWIP_DIR)core $(LWIP_DIR)core/ipv4 $(LWIP_DIR)core/ipv6 $(LWIP_DIR)netif
|
||||
lwip_SRC_DIR += $(LWIP_DIR)apps/*
|
||||
#lwip_SRC_DIR += $(LWIP_DIR)apps/*
|
||||
|
||||
$(eval $(call component_compile_rules,lwip))
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
static const uint32_t pp_zeros[8];
|
||||
void *_ppz20(size_t n)
|
||||
{
|
||||
return &pp_zeros;
|
||||
return (void*)&pp_zeros;
|
||||
}
|
||||
|
||||
#if OPEN_LIBPP_PP
|
||||
|
||||
@ -30,7 +30,7 @@ ESPPORT ?= /dev/ttyUSB0
|
||||
ESPBAUD ?= 115200
|
||||
|
||||
# firmware tool arguments
|
||||
ESPTOOL_ARGS=-fs $(FLASH_SIZE)m -fm $(FLASH_MODE) -ff $(FLASH_SPEED)m
|
||||
ESPTOOL_ARGS=-fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_SPEED)m
|
||||
|
||||
|
||||
# set this to 0 if you don't need floating point support in printf/scanf
|
||||
@ -88,9 +88,9 @@ WARNINGS_AS_ERRORS ?= 0
|
||||
# Common flags for both C & C++_
|
||||
C_CXX_FLAGS ?= -Wall -Wl,-EL -nostdlib $(EXTRA_C_CXX_FLAGS)
|
||||
# Flags for C only
|
||||
CFLAGS ?= $(C_CXX_FLAGS) -std=gnu99 $(EXTRA_CFLAGS)
|
||||
CFLAGS ?= $(C_CXX_FLAGS) -std=gnu11 $(EXTRA_CFLAGS)
|
||||
# Flags for C++ only
|
||||
CXXFLAGS ?= $(C_CXX_FLAGS) -std=c++0x -fno-exceptions -fno-rtti $(EXTRA_CXXFLAGS)
|
||||
CXXFLAGS ?= $(C_CXX_FLAGS) --std=c++20 -fno-exceptions -fno-rtti $(EXTRA_CXXFLAGS)
|
||||
|
||||
# these aren't all technically preprocesor args, but used by all 3 of C, C++, assembler
|
||||
CPPFLAGS += -mlongcalls -mtext-section-literals
|
||||
@ -130,10 +130,10 @@ CPPFLAGS += -DGITSHORTREV=$(GITSHORTREV)
|
||||
LINKER_SCRIPTS += $(ROOT)ld/program.ld $(ROOT)ld/rom.ld
|
||||
|
||||
# rboot firmware binary paths for flashing
|
||||
RBOOT_CONF ?= $(ROOT)bootloader/firmware_prebuilt/blank_config.bin
|
||||
RBOOT_ARGS ?= 0x0 $(RBOOT_BIN) 0x1000 $(RBOOT_CONF)
|
||||
RBOOT_BIN = $(ROOT)bootloader/firmware/rboot.bin
|
||||
RBOOT_PREBUILT_BIN = $(ROOT)bootloader/firmware_prebuilt/rboot.bin
|
||||
RBOOT_CONF = $(ROOT)bootloader/firmware_prebuilt/blank_config.bin
|
||||
|
||||
# if a custom bootloader hasn't been compiled, use the
|
||||
# prebuilt binary from the source tree
|
||||
|
||||
@ -74,13 +74,13 @@ def main():
|
||||
print("Reading from stdin...")
|
||||
port = sys.stdin
|
||||
# disable echo
|
||||
try:
|
||||
try:
|
||||
old_attr = termios.tcgetattr(sys.stdin.fileno())
|
||||
attr = termios.tcgetattr(sys.stdin.fileno())
|
||||
attr[3] = attr[3] & ~termios.ECHO
|
||||
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, attr)
|
||||
except termios.error:
|
||||
pass
|
||||
attr = termios.tcgetattr(sys.stdin.fileno())
|
||||
attr[3] = attr[3] & ~termios.ECHO
|
||||
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, attr)
|
||||
except termios.error:
|
||||
pass
|
||||
|
||||
try:
|
||||
while True:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user