Fixed by zeroing the memory. A more "c++ correct" approach
may be to add an additional op for equality, and use the "=="
operator on the F type in the generate function. But this adds
the requirement that F supports equality.
Fix a calculation error in in powerdown_nvic preventing the last
group of 32 interrupts from getting powered down. The ARMv7m reference
manual states "the total number of interrupt lines is up
to (32*(INTLINESNUM+1)).".
Also rename isr_count to isr_groups_32 for clarity, since this is
actually the number of 32 interrupt groups.
- Removed the patterned LED sequence, all boards now use the 4 fast pulse, 4 slow pulses LED sequence.
- Changed the LED used from LED_RED to LED1. Only 58/174 targets seem to define LED_RED but they all define LED1.
- Removed all ERROR_RED and ERROR_PATTERN definitions from targets/targets.json
The current error sequence for microcontrollers with less than 4 LEDs is
to toggle an LED at a fixed rate. Change the sequence to 4 short pulses
followed by 4 long pulses.
A define which expands to more defines is not portable across all
compilers and GCC warns about this. Restructure this so the behavior
is defined. This fixes the GCC warning:
"this use of "defined" may not be portable"
This is as it used to be, reverting the removal. uARM does not have any hook
that we could use for mbed sdk init and copy nvic, therefore _open is used that
should be sufficient, but not ideal.
For more information, visit https://github.com/ARMmbed/mbed-os/pull/2160/files#r76563844.
Before rtx 5, the max count on semaphores was UINT16_MAX, aftewards it
was decreased to 1024 with an assert on overflow.
This is especially problematic for semaphores used for signaling, since
there is no replacement currently available in C++.
Latest cmsis files provide virtual nvic implementation, therefore all nvic
set/get vectors were removed. As the result, we did not reallocate vectors
for mbed SDK. This should fix it for most of the platforms (cortex m0 and
cortex a9 need to provide own if they need it).
The use of mktime was causing a fault when called in interrupt handler because on GCC it lock the mutex protecting the environment, To overcome this issue, this patch add dedicated routine to convert a time_t into a tm and vice versa.
In the process mktime has been optimized and is now an order of magnitude faster than the routines present in the C library.
According to the C99 specification "The value (time_t)(-1) is returned if the
calendar time is not available". Before this patch, in such case the function
was returning 0 instead of -1.
The old open/opendir functions did not provide a route for errors and
relied on implementations manually setting errno. Updated to return
errors directly.
Required for other representations of FileSystems, ie LocalFileSystem
Introduces FileSystemHandle for the same behaviour as FileHandle and
DirHandle.
Requires the following to hook into file/dir lookup:
```
int open(FileHandle **file, const char *filename, int flags)
int open(DirHandle **dir, const char *path)
```
This hook is provided by the FileSystem class, so requires no changes
from implementations.
Trigger an assert if a file is read from or written to from an
interrupt handler or critical section. This includes using printf
from an interrupt handler or critical section. This makes failures
due to use in incorrect context deterministic and easier to locate.
This feature is enabled by defining MBED_TRAP_ERRORS_ENABLED to 1 or
by using the debug profile.
For keep supporting external APIs with the same name (supposedly there are a larger
number of users of those APIs), BufferedSerial and ATParser are being renamed.
BufferedSerial becomes UARTSerial, will complement a future USBSerial etc.
ATParser becomes ATCmdParser.
* UARTSerial moves to /drivers
* APN_db.h is moved from platform to cellular/util/.
* Original CellularInterface is restored for backward compatability (again, supposedly there
are users of that).
* A new file, CellularBase is added which will now servce as the base class for all
upcoming drivers.
* Special restructuring for the driver has been undertaken. This makes a clear cut distinction
between an on-board or an off-board implementation.
- PPPCellularInterface is a generic network interface that works with a generic FileHandle
and PPP. A derived class is needed to pass that FileHandle.
- PPPCellularInterface provides some base functionality like network registration, AT setup,
PPP connection etc. Lower level job is delegated to the derived classes and various modem
specific APIs are provided which are supposed to be overridden.
- UARTCellularInterface is derived from PPPCellularInterface. It constructs a FileHandle and
passes it back to PPPCellularInterface as well as provides modem hangupf functionality.
In future we could proive a USBInterface that would derive from PPPCellularInterface and could
pass the FileHandle back.
- OnboardCellularInterface is derived from UARTCellularInterfae and provides hooks to
the target provided implementation of onbard_modem_api.h. An off-board modem, i.e, a modem on
a shield has to override the modem_init(), modem_power_up() etc as it cannot use
onboard_modem_api.h.
There is currently no proper wake up mechanism provided
by mbed-os. _poll_change() was supposed to wake upa blocking
poll() in case of a POLL event but the implementation was dependent
upon underlying wake up mechanism. In the absence of conditioanl
variables or some other alternative, _poll_change() wasn't able to
serve its purpose. Removing it for now. Should be implemented at some later stage
Make FileHandle more of an interface class, by requiring implementers to
provide the sigio() functionality themselves.
sigio() and poll() remain parallel independent mechanisms, so FileHandle
implementations must trigger both on state changes.
* state machine corrections
* adding various standard API methods
* Addition/revision/enhancement of the nsapi_ppp glue layer
* Turning off debug by default
Mainly reutilizing code from ublox C027 support lib.
As we are using external PDP context, i.e., an external IP stack,
we will pass username and password to underlying stack running PPP.
We only support CHAP as the authentication protocol.
POSIX poll() provides a mechanism to attach a POLL_HUP event
if the modem or device hangs up on you. POLL_HUP and POLL_OUT are
mutually exclusive. We poll in the PPP_input() routine if the modem
hung up. If it did we stop the data consumption, close PPP and go back
to the driver for reserruction of AT parser and subsequent retries or
application specific actions.
This is achieved by attaching an interrupt to the DCD line of the modem.
When DCD line goes high (off), we have lost the carrier. So we record an
POLLHUP event using _poll_change().
ATParser had been using std <vector> which had been pulling along a lot
of standard C++ stuff. We have an alternative implementation whcih achieves
a similar effect but without using <vector>. this saves a bunch of valuable
RAM resource.
We have also simplified the overall system by introducing proper CR and LF
rather than \r\n type of delimiters. This newline simplification is borrowed
from retarget.cpp.
Existing ATParser is extended to use FileHandle. This essentially detaches
ATParser from previous tight binding with various implementations of serial
interfaces with buffering.
Now the ATParser uses only abstract FileHandle and doesn't really care about
the underlying implementation. Underneath, it could be a USB device type FileHandle
or a Serial device type FileHandle etc.
Some simplification steps were taken as the code provided opportunities to simplify
and optimize.
BufferedSerial is a FileHandle and using SerialBase.
It keeps the SerialBase private however lets the user extend FileHandle
by keeping it public.
It is using CircularBuffer class for having circular buffers.
There are some minor amendments in CircularBuffer too.
Adding an entry for tx/rx buffer sizes in platform/mbed_lib.json.
Default size is 256 bytes.
For RTOS read(), write() calls yield for other threads to carry on with their stuff.
For non-RTOS blovking read or write would mean a loop where 100 percent resources are
consumed by this loop. Need to get a better implementation in. Currently no mechanism to
wake the mcu up after WFE.
mbed::fdopen() is provided in mbed_retarget.cpp which will attach a stream to the
given FileHandle. Removing mbed_set_unbuffered_stream() from stream class as it
is defined in mbed_retarget.cpp. Stream class should not decide whether it wants
to detach buffers from c library or not. mbed::fdopen() will do that based upon
isatty() call. So if a FileHandle is not a tty, i.e., is not a device type, c library
buffering will not be turned off. For device type FileHandles, c library buffering
is turned off.
This has been an attempt to extend existing FileHandle to behave like POSIX
file descriptor for input/output resources/devices too.
This will now provide an abstract indicator/handle any arbitrary file or device
type resource. May be in future, sockets too.
In order to correctly detect availability of read/write a FileHandle, we needed
a select or poll mechanisms. We opted for poll as POSIX defines in
http://pubs.opengroup.org/onlinepubs/009695399/functions/poll.html Currently,
mbed::poll() just spins and scans filehandles looking for any events we are
interested in. In future, his spinning behaviour will be replaced with
condition variables.
In retarget.cpp we have introduced an mbed::fdopen() function which is
equivalent to C fdopen(). It attaches a std stream to our FileHandle stream.
newlib-nano somehow does not seem to call isatty() so retarget doesn't work for
device type file handles. We handle this by checking ourselves in
mbed::fdopen() if we wish to attach our stream to std stream. We also turn off
buffering by C library as our stuff will be buffered already.
sigio() is also provided, matching the API of the Socket class, with a view to
future unification. As well as unblocking poll(), _poll_change calls the user
sigio callback if an event happens, i.e., when FileHandle becomes
readable/writable.
* Don't set errno when calls are successful (will slightly alleviate the problem
of errno not being thread-safe yet).
* Transfer errors returned from size() and seek() into errno.
* Fix isatty() - could never return 1 from a FileHandle.
* Use more appropriate errors than EBADF in some places (eg ENOENT for non-existant path).
failing on file allocation / opening during Stream creation.
The consequence was application continues running, but any printf
to the Serial object whose Stream was not properly created
would not show any error (and characters would not show either)
Let's add a check to properly inform user of the error.
[Warning] mbed_board.c@99,36: comparison between signed and unsigned
integer expressions [-Wsign-compare] is seen during compilation.
Fix the warning and small improvements.
1. Change type of loop variable "i" to the same type as "size".
Size is > 0 checked by the if statement and i stops at == size
so none can be negative. However size still needs to be signed
to detect error codes from vsnprintf.
2. Reduced scope of stdio_out_prev and make sure it's initialized.
3. Define a name for the error buffer size and use vsnprintf instead
of vsprintf to avoid writing outside of the array.
NOTE: the if(size > 0) statement doesn't need to change. If
the message to write is larger than the buffer size vsnprintf
truncates it automatically but still returns a positive value.
Fix the following compiler warning.
Compile [ 63.7%]: mbed_board.c
[Warning] mbed_board.c@99,36: comparison between signed and unsigned integer expressions [-Wsign-compare]
Signed-off-by: Tony Wu <tonyw@realtek.com>
stop using scope for \addtogroup. It was placing class methods into the
group documentation instead of the class documentation. The new style is
to explicitly tag the class as @ingroup. This new method will allow the
class to be linked in the group page, and the class page will contain
the detailed documentation of the class methods.
The current implementation of semihost_disabledebug() hangs when used
with mbed interface firwmare revision 21164, the first version which
added support for this semihost call. I encountered this hang when
running a Release build on my mbed-LPC1768 board as the RTOS attempted
to disable the debugger before the idle thread put the CPU to sleep.
The 21164 interface firmware expects that R1 points to a valid argument
block but the current implementation passes in NULL. The fix was to
pass in a dummy block which is ignored by the newer 141212 revision of
the firmware and allows the 21164 version to proceeed without halting
the CPU until a manual reset.
Before this fix semihost_disabledebug() did work with the latest
mbed interface firmware revision 141212 but I rarely use this revision
of the interface firmware due to the instability issues I have
encountered in the past with its CDC and LocalFileSystem functionality.
With this proposed fix, the code now works with both the 21164 and
141212 revisions of the mbed interface firmware on the mbed-LPC1768.
This patch fixes the declaration of the DIR type and related functions
so that they can be called from C code. This is necessary when enabling
functionality that uses the filesystem in mbed TLS.
Should follow same path as FileHandle, although this is less used
and there is currently no route to introduce a hook for a customized
DirHandle in retarget.
As identified by @hasnainvirk, @kjbracey-arm, the FileHandle and
FileBase serve two separate functions and their integration is
limiting for certain use cases.
FileLike is actually the redundant class here, but the multiple
inheritance it provides is used as a hack by the retargeting code
to get at the FileHandle implementation bound to the FileBase name.
It may make more sense for the FileBase to inherit from FileHandle,
(with perhaps a different name), but rather than explore the
possibility, this will just restore the previous hierarchy.
- Fixing code formatting errors with astyle tool.
- Replaced use of TOOLCHAIN_xxx macros with compiler emitted macros.
- Added const to BlockDevice::get_xxx_size() member functions.
- Added documentation for FAT filesystem thread support.
- Added documentation for fat_filesystem_set_errno().
- Added documentation clarifying the reasons for errno/stat symbol definitions in retarget.h.
- Removed FAT filesystem from mbed 2 testing.
- Fixed FATMisc.h Copyright (c) 2016 year to 2017 as its a new file.
- Removed #ifndef NDEBUG from HeapBlockDevice.cpp.
- Removed unnecessary todo comment in retarget.cpp.
- renaming FATFileSystemSetErrno() fat_file_system_set_errno.
- changing FATFileSystem::format() to be mount fs internally in function, rather than expecting fs to be mounted.
- requested const char *filename change.
The attach function is used several other places to indicate
registration for interrupts. This differs significantly to its use in
the Callback class. Additionally, the attach function is unnecessary
given that simple assignment works just as well.
MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES was not used in mbed_error_vfprintf causing wrong behavior when the option was selected (no new line is some terminals like putty).
Add sleep/deepsleep functions to platform layer which are replacing HAL
functions with the same name, rename existing symbols in HAL layer
to hal_sleep/hal_deepsleep. This way sleep functions
are always available, even if target doesn't implement them, which makes
the code using sleep clearer. It also enables us to make decision on in
which builds (debug/release) the sleep will be enabled.
Adopting relaxed type-deduction in bound functions better aligns with
the same overloads for member functions, and provides an alternative
solution for the void pointer cast issue, which removes a large amount
of cruft.
The type deduction for the callback constructors was to strict and
prevented implicit casts for the context pointer stored internally.
As noted by @pan-, relaxing the contraints on the templated
parameters allows C++ to correctly infer implicit casts such as
conversions between child and parent classes when inheritance is
involved.
As an additional benefit, this may help the user experience by
defering invalid type errors to when the types are expanded,
limiting the number of error messages presented to users.
Added MBED_STATIC_ASSERT for compile-time assertions, results in
compile-time error if condition is false
The assertion acts as a declaration that can be placed at file scope, in
a code block (except after a label), or as a member of
a C++ class/struct/union.
Unfortunately, there does not exist a backup construct for use in
C class/struct/union contexts. An alternative macro,
MBED_STRUCT_STATIC_ASSERT provides this ability to avoid disabling
static assertions for the majority of mbed-supported C compilers.
In uARM, the library's hook _platform_post_stackheap_init does not seem to
exist and I couldnot find a documentation describing the initialisation
flow. All we know is that _open is called after RAM init and before the
C++ init, so this is a working placeholder.
This is maybe not acceptable so a uARM lib expert may propose a better
hook to fullfil the requirement.
At least this is a workign setup.
This series should solve issue reported here:
STM32 (At least F401) breaks if Tickers are activated in a global object #2115
Various toolchains supported in MBED don't followthe same initialization
steps. This can have impacts on platform behavior.
For STM32, it is needed to call the HAL_Init() _after_ the RAM has been
initialized (sdata from flash / zero initialized data) and _before_ the C++
objects are being created, especially if those objects require support
of tickers for instance.
In GCC and IAR, this was done in previous commit to avoid HAL_Init()
to be called twice.
In ARM this there is no hook defined in MBED yet to place the call.
The proposal is to take benefit of the library's
_platform_post_stackheap_init function that is going to be called before
__rt_lib_init where the C++ object init is done (__cpp_initialize__aeabi_)
This series should solve issue reported here:
STM32 (At least F401) breaks if Tickers are activated in a global object #2115
In the IAR ide, implicitly generated structures based on function
templates end up with missing type information. This has no effect
on using the IAR compiler standalone, but when used through the ide
the missing type information causes the ide to error.
As a workaround, moved the function attributes generated for the
Callback and Event classes into the class scope. This avoids the
syntax that confuses IAR.
This commit adds a `baud` argument for Serial and RawSerial objects:
- there is a new `Serial` constructor with a mandatory baud rate
argument. The old constructor also got a `baud` argument with a
default value (to keep backward compatibility).
- the `RawSerial` constructor also got a `baud` argument with a default
value.
There's also a new configuration parameter (`default-serial-baud-rate`)
that can be used to specify the default value of the above `baud`
arguments.