Conflicts:
.gitignore
src/common_tmr.c
src/platform/lm3s/platform.c
src/platform/lm3s/platform_conf.h
src/platform/sim/platform_conf.h
src/platform/stm32/platform_conf.h
src/platform/str9/platform_conf.h
utils/build.lua
Also fixed some minor issues in the builder.
There is a new command in the shell ('mv' - move/rename files).
Also, the shell code was refactored into its own directory (src/shell).
The 'help' command in the shell was updated and supports 'help <command>'.
There is a new BUILD_ADVANCED_SHELL build time macro that enables the
advanced shell features (currently 'cp' with recursion (and other improvements),
'mv' and 'rm').
- For now only supported for MMCFS
- 'dir' function in shell augmented to show directories and
to traverse a path recursively if requested
- new command 'mkdir' in shell
This should really be more than one commit, but I wrote everything in one
shot and I don't feel like arranging the changes logically into different
commits. So, these are the changes:
- added WOFS (Write Once File System). This is a writeable file system that
exists in the MCU's internal Flash memory and allows files to be written,
but only once, in a single shot. More details to follow.
- the platform interface has a new MCU flash access interface.
- added WOFS "reference implementations" for two CPUs: LM3S8962 and
STM32F103RE. They are easily extendable to other CPUs in the same platform
and can be taken as a model for other platforms.
- the ROMFS file layout in memory was slightly changed.
- the simulator (src/platform/sim) got a new function (lseek).
- shell: now each shell command receives its arguments in a C-main-style
(argc, argv) pair. This was originally Marcelo's idea and it finally
made it to the master (although this particular implementation is mine),
after I got fed up with all the argument parsing in the shell functions.
- new shell command: wofmt ("formats" a WOFS, effectively clearing it).
- a couple of small fixes in the shell code
All the functions that implement a FS receive the instance data
of the FS (given at registration time to dm_register) as their
last argument. ROMFS was changed to take advantage of this.
Now it's possible to have more than one instance of a given file
system. For example, one could use more that one ROM file system
in different physical locations (a possible configuration is
internal Flash and external serial memories). This mechanism is
currently implemented only in the device manager (devman.c),
actual instance implementation require per-FS support (to be
implemented later).
This patch adds more RAM optimizations to eLua:
- direct file memory mapping: files in ROMFS will be read directly from Flash,
without allocating any additional buffers. This doesn't help with RAM
consumption in itself, but enables the set of optimizations below.
- pseudo read-only strings. These are still TStrings, but the actual string
content can point directly to Flash. Original Lua strings are kept in
TStrings structures (lobject.h):
typedef union TString {
L_Umaxalign dummy; /* ensures maximum alignment for strings */
struct {
CommonHeader;
lu_byte reserved;
unsigned int hash;
size_t len;
} tsv;
} TString;
The actual string content comes right after the union TString above.
Pseudo RO strings have the same header, but instead of having the string
content after TString, they have a pointer that points to the actual
string content (which should exist in a RO memory (Flash) that is directly
accesbile from the MCU bus (like its internal Flash memory)). lua_newlstr
detects automatically if it should create a regular string or a pseudo RO
string by checking if the string pointer comes from the Flash region of the
MCU. This optimization works for both precompiled (.lc) files that exist in
ROMFS and for internal Lua strings (C code).
- functions in Flash: for precompiled (.lc) files that exist in ROMFS, the code
of the functions and a part of the debug information will be read directly
from Flash.
- ROMFS was changed to support files that are larger than 2**16 bytes and it
aligns all its files to an offset which is a multiple of 4 in order to prevent
data alignment issues with precompiled Lua code.
- the Lua bytecode dumper was changed to align all the instructions in a Lua
function and a part of the debug information to an offset which is a multiple
of 4. This might slightly increase the size of the precompiled Lua file.
These changes were succesfully checked against the Lua 5.1 test suite.
These changes were tested in eLua on LM3S and AVR32.
This patch undoes the change in the order of timer parameters for:
net.accept() net.recv() tmr.delay() tmr.setclock() tmr.set_match_int()
tmr.gettimediff() and also changes the new tmr.getdiffnow() to have the
same parameter ordering as the others.
The default timer ID (the systimer), which previously was obtained with an
optional last parameter, is now obtained by supplying nil as the timer ID.
tmr.getmaxdelay() used to return -1 for the system timer and -2 for
virtual timers in the integer build due to Lua integers being signed.
This makes them return 2147483647 and 2147483646 resectively.
Fixed an error which made the getmindelay/getmaxdelay functions
invalid (thanks to Martin for spotting this). Also refactored the
code that computes min/max delay from platform files to common code.
Since the system timer might be too demanding for some platforms
(although this isn't currently the case for any eLua plarform) it
is now optional. Any platform that implements it must define the
PLATFORM_HAS_SYSTIMER macro in its platform_conf.h
When a systimer timer overflow is detected, handle it by temporarily disabling
the systimer interrupt rather than disabling the systimer completely. It gives
better accuracy and fixes some hardware-related issues on some platforms.
- the infinite timeout value is again represented by a special value
(not a special timer ID), but this time it's a non-negative value
- all timers in the UART module default to the system timer
- all timers in the TMR module default to the system timer
- implemented a generic system timer mechanism that can be used in
conjunction with a timer interrupt.
- implemented system timers on LM3S (tested) and STM32 (not tested).
Both are based on the Cortex M3 SysTick timer.
- added explicit support for the system timer in common_tmr.c
- all the functions in the tmr module will now use the system timer
by default (if no id is specified)
- infinite timeout will be specified by using a special timer ID
rather than using negative timeout values (this allows the timer
data type to be unsigned and increases the timer range)
platform_pwm_op( id, op, data ) did four unrelated tasks, switching on the
"op" parameter:
op==PLATFORM_PWM_OP_SET_CLOCK took a frequency and returned a frequency
op==PLATFORM_PWM_OP_GET_CLOCK took nothing returned a frequency
op==PLATFORM_PWM_OP_START and _STOP both took nothing and returned nothing
this patch replaces it with:
clock = platform_pwm_set_clock( id, clock)
clock = platform_pwm_get_clock( id )
platform_pwm_start( id ) and
platform_pwm_stop( id )
with resulting clarity in the documentation and smaller, faster code.
This does not affect the Lau interface.
Previously, you called platform_adc_op(id, OPERATION, u32 arg) to achieve
six unrelated functions with different arg types and return values:
GET_MAXVAL takes nothing and returns an ADC conversion value
SET_SMOOTHING takes a power-of-two filter length and returns nothing
SET_BLOCKING takes a boolean and returns nothing
IS_DONE takes nothing and returns a boolean
SET_TIMER takes a timer ID and returns nothing
SET_CLOCK takes a frequency in Hz and returns a frequency in Hz.
This changes these to six independent functions, each with the right
parameters and return values.
This also makes the documentation more comprehensible, saves 26 bytes of
executable code and should be very slightly faster.
elua_mmc.c uses the virtual timer tick to implement its timeout delays,
and needs MMCFS_TICK_HZ to have the same value as VTMR_FREQ_HZ.
This corrects the mismatch on AVR32 platforms and adds a check to
validate.h to ensure that it remains so.
Tabs have been creeping in to eLua's source files, sometimes representing
2 characters, sometimes 8. This patch replaces them all with the appropriate
number of spaces, according to the context.
This only fixes files that were written specifically for eLua, not the
manufacturers' SDK source files that were simply imported into the tree.