1
0
mirror of https://github.com/elua/elua.git synced 2025-01-25 01:02:54 +08:00

166 Commits

Author SHA1 Message Date
Bogdan Marinescu
9dffa3ce81 New feature: memory error callback
This PR adds the possibility of specifying a memory error callback in
the "ram" element of the "config" section. The new configuration
attribute is called "memory_error_callback" and its value is the name of
a function with the signature "void f(size_t)" that will be called
automatically in the following cases:

- when malloc, calloc, or realloc (with the 'size' argument greater than
  0) return NULL. The callback function will be called with the 'size'
  argument of the allocation function.
- when the allocator encounters an internal error (only when using the
  'multiple' allocator). The callback function will be called with the
  argument set to 0.

For now, this feature is only availabsle when using the multiple
allocator or the simple allocator, not the built-in libc allocator.

Usage example (in the board configuration file):

```
   config = {
     ram = { memory_error_callback = "memory_error" }
   }
```
2018-06-11 21:48:46 +03:00
Jeff Palmer
b3de8d2155 Configurable shell messages
This commit adds the possibility to configure various shell messages (and some
internal variables) by defining the respective macros at compile time.
2018-06-01 01:36:54 +03:00
James Snyder
75e8dcdf59 Added more terminal functions
Added save position, restore position and set scroll to the terminal
functions. See https://ttssh2.osdn.jp/manual/en/about/ctrlseq.html for a
description of the new sequences.
2018-05-30 18:57:23 +03:00
Bogdan Marinescu
7423ae2a18 Update dlmalloc to version 2.8.6
Also added a new function to the `elua` module: `heapstats`.
2018-05-23 22:43:06 +03:00
Bogdan Marinescu
69c653accd New file system: NIFFS
For more details check https://github.com/pellepl/niffs.
2018-05-19 23:02:27 +03:00
Thomas Hornschuh
d0a6375202 Added support for 1K xmodem
Preliminary support for 1K xmodem. Should make it configurable.
2017-08-03 16:29:31 +02:00
Thomas Hornschuh
427ea3970f Changed net.accept behaviour
The original implementation of net.accept did not unlisten the port
after returing. So additional clients can connect to the port, but the
connection is not used. The easiest way to solve this, is to make an
unlisten() call before returning from accept. But I think it is better
to separate listen/unlisten from accept and let the system allow
accepting new connections in the background which can be later taken
with a call to accept. This allows for example using a coroutine waiting
for new connections with a non-blocking accept loop and a yield call.
This commit contains everything to implement the new behaviour and also
add the methods net.listen and net.unlisten. To be compatible with the
old semantics net.accept automatically calls listen to the port.

In addtion the error handling of accept was changed in a way that a
timeout returns the new return value net.ERR_WAIT_TIMEDOUT instead of
returning -1. I find this more consistent.
2017-07-30 20:52:27 +02:00
Martin Guy
30ee5de1f9 Add check for console on USB serial port but USB CDC not enabled.
Before this, you could put the console on USB CDC without BUILD_USB_CDC
and eLua compiled OK but nothing worked. This change makes it spit out
an appropriate message if that should happen again.
2014-05-16 14:36:59 +02:00
James Snyder
8405e9bbbb Make LuaRPC funcname long enough for null termination 2014-04-15 10:59:44 -05:00
ecdr
7dc3b36b52 platform.h - note unused constants
PLATFORM_SPI_TOTAL, PLATFORM_UART_TOTAL, PLATFORM_PWM_TOTAL

TODO: Figure out purpose, or remove them
2014-03-19 21:48:56 -08:00
Mark Burton
a9fd03053d Correct value of PLATFORM_TIMER_SYS_MAX for lua long builds.
It was being set to ( ( 1LL << 31 ) - 2 ) which only used 31 bits when 32
are available. By setting it to ( ( 1LL << 32 ) - 2 ) the range of the timer
is doubled to around 4295 seconds. Note that time values greater than
approx 2147 seconds will have the top bit (1 << 31) set and so will appear
to be negative as all numbers are considered to be signed.
2014-02-02 11:08:37 +00:00
Bogdan Marinescu
0e504711c9 Merge pull request #36 from smartavionics/mb-can-send-result
Add status return to can.send() and underlying platform_can_send() functions.
2014-01-27 00:15:29 -08:00
Mark Burton
e120b9dc14 Add status return to can.send() and underlying platform_can_send() functions.
Now, can.send() returns a boolean result to indicate whether the message
was successfully sent or not. The various platform functions differ in how
they handled the situation where all CAN transmitters are occupied. In
particular, the STM32x and STR9 implementations ignored the status returns
from the underlying libraries and so if all the CAN transmitters were busy,
the latest message simply got thrown away. Now, can.send() returns true/false
to indicate if the message really did get queued for transmission. All
platforms should behave the same as before.
2014-01-25 19:29:33 +00:00
ecdr
608df36d0c eLua - mmcfs - suppress warnings (prototypes, static functions) 2014-01-22 14:17:48 -08:00
James Snyder
62936ace5e add back modules to luarpc desktop 2013-11-21 15:47:34 -06:00
ecdr
ee3a3be740 eLua - platform_conf.h - update many out of date references
The material that used to be in platform_conf.h has
been split to several files, including:
platform_ints.h, cpu_xxxx.h, and in the board.lua.

Still more fixes needed in documentation.
2013-10-30 13:35:17 -08:00
ecdr
9f81cca6b8 Lua, eLua - Add function prototypes, fix shellh_ask_yes_no prototype 2013-10-30 00:44:15 -08:00
ecdr
4990f27486 eLua - clarify function prototypes - list arguments as void 2013-10-30 00:42:17 -08:00
ecdr
8c4f6d1549 eLua - Remove redundant includes
duplicate files included by platform.h/platform_conf.h
2013-10-30 00:38:46 -08:00
ecdr
f38162e92e eLua - Disambiguate duplicate serial.h
(renaming fixes name overlap with serial.h in SAM drivers)
2013-10-30 00:29:57 -08:00
ecdr
6d9676b7b1 eLua - UART - add platform constants for mark and space parity 2013-10-30 00:28:48 -08:00
James Snyder
98d2a678b3 update copyright date range 2013-08-14 17:37:21 -05:00
James Snyder
2f48b8da92 ensure that modules get included for luarpc desktop build 2013-08-14 17:13:42 -05:00
Bogdan Marinescu
91946fc05e STM32F4 CDC UART support + other CDC changes
This should really be more than one commit, but here it goes anyway:

- added STM32F4 CDC UART support. For some reason, it seems to work only
on the OTG_FS interface, the OTG_HS interface enumerates it, but
doesn't seem to send/receive any data.
- removed the "platform interface" functions for CDC UART. That was
never really a platform interface, just a couple of functions reading
and writing data from/to a CDC UART. Now each backend takes care of this
as a special case in its platform_uart_xxx functions.
- added buffering support for CDC UARTs
- added uart.CDC to the uart module, so the CDC uart can be used directly
from Lua.
- stm32f4discovery now defaults to using the CDC, since it doesn't have
a dedicated UART connector.
2013-06-26 01:04:34 +03:00
Bogdan Marinescu
5f6ca7d033 merged github master 2013-05-28 12:26:48 +03:00
Bogdan Marinescu
cc459c1543 Multiple changes
- added GPIO driver to XMC4000
- new functions for the PIO module / updated docs
2013-05-18 22:09:02 +03:00
Bogdan Marinescu
463f0bceda Merge branch 'master' into luabuild
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.
2013-04-25 16:55:29 +03:00
Bogdan Marinescu
1d43a6e905 updated version.h for consistency 2013-04-01 23:10:36 +03:00
Bogdan Marinescu
ee737d717e improved file type reporting 2013-01-16 01:54:34 +02:00
Bogdan Marinescu
5d97e95489 Shell commands are now callable from the 'elua' module
Simply use 'elua.shell( <command> )', for example:

elua.shell( "ls /rom" )

In called like this, "lua" and "exit" are disallowed.
2012-11-14 00:00:24 +02:00
Bogdan Marinescu
e42b88561a 'mv' command and shell code refactoring
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').
2012-10-07 23:54:28 +03:00
Bogdan Marinescu
2402627a10 Adding rm and rmdir commands to the shell (WIP) 2012-10-03 02:52:39 +03:00
Bogdan Marinescu
389ce9b41a More improvements to the shell (WIP)
- file masks ('*' and '?' are now accepted)
- recursive operations for ls/cp
- new FS-specific functions (src/common_fs.c)
2012-09-19 00:09:39 +03:00
Bogdan Marinescu
9e7f1ab4cd Preliminary directory support
- 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
2012-09-10 19:12:15 +03:00
Bogdan Marinescu
aa529adf9b et-stm32 board description file DONE + other fixes/improvements 2012-07-12 01:50:38 +03:00
Bogdan Marinescu
59beff6b99 working on the new build configurator. starting to get shape 2012-07-01 01:07:59 +03:00
Bogdan Marinescu
a9ebeac525 WOFS fix: at most one file opened in write mode
Due to the nature of WOFS, at most one file can be opened on WOFS
in write mode at any given time.
2012-06-25 20:32:29 +03:00
Bogdan Marinescu
e9a24cac11 Added WOFS + other stuff
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
2012-06-24 23:07:32 +03:00
Bogdan Marinescu
ed54aec47a Added FS registration data as argument to all FS functions
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.
2012-06-19 00:51:56 +03:00
Bogdan Marinescu
a199d47615 Changed FS registration mechanism
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).
2012-06-17 14:04:51 +03:00
Bogdan Marinescu
d54659b572 RAM optimizations: pseudo RO strings, functions in Flash
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.
2012-05-10 00:39:42 +03:00
Martin Guy
90897d2d02 Save 4 bytes RAM per structure by reordering struct members
Structure size is 12 byte instead of 16 with GCC on x86,
probably also on others.
2012-02-26 04:14:53 +01:00
Martin Guy
69eb5cc478 Put the order of timer parameters back to what it used to be
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.
2012-01-21 17:30:38 +02:00
Martin Guy
a5a20783a9 Fix tmr.getmaxdelay() with virtual and system timers when LUA_NUMBER_INTEGRAL
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.
2012-01-15 06:37:13 +01:00
Bogdan Marinescu
66975786cf Fixed error in getmindelay/getmaxdelay
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.
2011-11-28 22:58:10 +02:00
James Snyder
1b678dfea2 Merge branch 'master' into lm3s_usb_cdc 2011-11-13 17:41:23 -06:00
James Snyder
8c0f82198f Fix CRLF 2011-10-24 19:11:35 -05:00
James Snyder
b7b6a6e7eb Add build-time check for system timer for MMCFS 2011-10-21 18:15:14 -05:00
James Snyder
c4f7fe94c1 Adjust MMCFS to use the system timer 2011-10-21 18:08:43 -05:00
Bogdan Marinescu
a46cc203c8 fix timeout data type in the RFS implementation 2011-10-13 14:12:05 +03:00