Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fpletz
firmware
Commits
e728833c
Verified
Commit
e728833c
authored
5 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
fix(pycardium): Remove all uses of newlib malloc
Fixes
#44
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
7a39ec76
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pycardium/meson.build
+1
-0
1 addition, 0 deletions
pycardium/meson.build
pycardium/mphalport.c
+6
-19
6 additions, 19 deletions
pycardium/mphalport.c
pycardium/patch.c
+71
-0
71 additions, 0 deletions
pycardium/patch.c
with
78 additions
and
19 deletions
pycardium/meson.build
+
1
−
0
View file @
e728833c
...
...
@@ -71,6 +71,7 @@ upy = static_library(
elf
=
executable
(
name
+
'.elf'
,
'main.c'
,
'patch.c'
,
'mphalport.c'
,
frozen_source
,
modsrc
,
...
...
This diff is collapsed.
Click to expand it.
pycardium/mphalport.c
+
6
−
19
View file @
e728833c
...
...
@@ -8,6 +8,7 @@
#include
"py/mpstate.h"
#include
"py/obj.h"
#include
"py/runtime.h"
#include
"py/mpprint.h"
#include
"mxc_delay.h"
#include
"max32665.h"
...
...
@@ -15,6 +16,7 @@
#include
"epicardium.h"
#include
"api/common.h"
/******************************************************************************
* Serial Communication
*/
...
...
@@ -36,30 +38,15 @@ int DEBUG_printf(const char *fmt, ...)
{
va_list
args
;
va_start
(
args
,
fmt
);
int
ret
=
vprintf
(
fmt
,
args
);
int
ret
=
mp_
vprintf
(
MP_PYTHON_PRINTER
,
fmt
,
args
);
va_end
(
args
);
return
ret
;
}
/* newlib syscall to allow printf to work */
long
_write
(
int
fd
,
const
char
*
buf
,
size_t
cnt
)
void
__attribute__
((
noreturn
))
sbrk_is_not_implemented___see_issue_44
(
void
);
intptr_t
_sbrk
(
int
incr
)
{
/*
* Only print one line at a time. Insert `\r` between lines so
* they are properly displayed on the serial console.
*/
size_t
i
,
last
=
0
;
for
(
i
=
0
;
i
<
cnt
;
i
++
)
{
if
(
buf
[
i
]
==
'\n'
)
{
epic_uart_write_str
(
&
buf
[
last
],
i
-
last
);
epic_uart_write_str
(
"
\r
"
,
1
);
last
=
i
;
}
}
if
(
last
!=
i
)
{
epic_uart_write_str
(
&
buf
[
last
],
cnt
-
last
);
}
return
cnt
;
sbrk_is_not_implemented___see_issue_44
();
}
void
epic_isr_ctrl_c
(
void
)
...
...
This diff is collapsed.
Click to expand it.
pycardium/patch.c
0 → 100644
+
71
−
0
View file @
e728833c
#include
"epicardium.h"
#include
<stdarg.h>
#include
<stdio.h>
#include
"py/mpprint.h"
#include
"py/mphal.h"
#include
<string.h>
int
printf
(
const
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
int
ret
=
mp_vprintf
(
MP_PYTHON_PRINTER
,
fmt
,
ap
);
va_end
(
ap
);
return
ret
;
}
#ifdef putc
#undef putc
#endif
/* putc */
int
putc
(
int
c
,
FILE
*
f
)
{
char
chr
=
(
char
)
c
;
mp_hal_stdout_tx_strn_cooked
(
&
chr
,
1
);
return
c
;
}
#ifdef putchar
#undef putchar
#endif
/* putchar */
int
putchar
(
int
c
)
{
char
chr
=
(
char
)
c
;
mp_hal_stdout_tx_strn_cooked
(
&
chr
,
1
);
return
c
;
}
int
puts
(
const
char
*
s
)
{
int
length
=
strlen
(
s
);
if
(
length
)
{
mp_hal_stdout_tx_strn_cooked
(
s
,
length
);
}
return
length
;
}
/* Used by mp_hal_move_cursor_back() */
int
snprintf
(
char
*
str
,
size_t
size
,
const
char
*
format
,
...)
{
/* TODO: What should we do with this? */
return
-
EIO
;
}
/* Use by assert() */
int
fiprintf
(
FILE
*
f
,
const
char
*
fmt
,
...)
{
/* TODO: Maybe printing everything to UART isn't the correct thing? */
va_list
ap
;
va_start
(
ap
,
fmt
);
int
ret
=
mp_vprintf
(
MP_PYTHON_PRINTER
,
fmt
,
ap
);
va_end
(
ap
);
return
ret
;
}
int
raise
(
int
sig
)
{
/* Ignore signals */
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment