Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
f6a35f76
Commit
f6a35f76
authored
Mar 09, 2023
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stm32/modmachine: Make machine.info print using mp_printf.
Signed-off-by:
Damien George
<
damien@micropython.org
>
parent
6c8b19c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
23 deletions
+24
-23
ports/stm32/modmachine.c
ports/stm32/modmachine.c
+24
-23
No files found.
ports/stm32/modmachine.c
View file @
f6a35f76
...
...
@@ -24,7 +24,6 @@
* THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include "modmachine.h"
...
...
@@ -163,24 +162,26 @@ void machine_deinit(void) {
// machine.info([dump_alloc_table])
// Print out lots of information about the board.
STATIC
mp_obj_t
machine_info
(
size_t
n_args
,
const
mp_obj_t
*
args
)
{
const
mp_print_t
*
print
=
&
mp_plat_print
;
// get and print unique id; 96 bits
{
byte
*
id
=
(
byte
*
)
MP_HAL_UNIQUE_ID_ADDRESS
;
printf
(
"ID=%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x
\n
"
,
id
[
0
],
id
[
1
],
id
[
2
],
id
[
3
],
id
[
4
],
id
[
5
],
id
[
6
],
id
[
7
],
id
[
8
],
id
[
9
],
id
[
10
],
id
[
11
]);
mp_printf
(
print
,
"ID=%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x
\n
"
,
id
[
0
],
id
[
1
],
id
[
2
],
id
[
3
],
id
[
4
],
id
[
5
],
id
[
6
],
id
[
7
],
id
[
8
],
id
[
9
],
id
[
10
],
id
[
11
]);
}
printf
(
"DEVID=0x%04x
\n
REVID=0x%04x
\n
"
,
(
unsigned
int
)
HAL_GetDEVID
(),
(
unsigned
int
)
HAL_GetREVID
());
mp_printf
(
print
,
"DEVID=0x%04x
\n
REVID=0x%04x
\n
"
,
(
unsigned
int
)
HAL_GetDEVID
(),
(
unsigned
int
)
HAL_GetREVID
());
// get and print clock speeds
// SYSCLK=168MHz, HCLK=168MHz, PCLK1=42MHz, PCLK2=84MHz
{
#if defined(STM32F0) || defined(STM32G0)
printf
(
"S=%u
\n
H=%u
\n
P1=%u
\n
"
,
mp_printf
(
print
,
"S=%u
\n
H=%u
\n
P1=%u
\n
"
,
(
unsigned
int
)
HAL_RCC_GetSysClockFreq
(),
(
unsigned
int
)
HAL_RCC_GetHCLKFreq
(),
(
unsigned
int
)
HAL_RCC_GetPCLK1Freq
());
#else
printf
(
"S=%u
\n
H=%u
\n
P1=%u
\n
P2=%u
\n
"
,
mp_printf
(
print
,
"S=%u
\n
H=%u
\n
P1=%u
\n
P2=%u
\n
"
,
(
unsigned
int
)
HAL_RCC_GetSysClockFreq
(),
(
unsigned
int
)
HAL_RCC_GetHCLKFreq
(),
(
unsigned
int
)
HAL_RCC_GetPCLK1Freq
(),
...
...
@@ -190,35 +191,35 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
// to print info about memory
{
printf
(
"_etext=%p
\n
"
,
&
_etext
);
printf
(
"_sidata=%p
\n
"
,
&
_sidata
);
printf
(
"_sdata=%p
\n
"
,
&
_sdata
);
printf
(
"_edata=%p
\n
"
,
&
_edata
);
printf
(
"_sbss=%p
\n
"
,
&
_sbss
);
printf
(
"_ebss=%p
\n
"
,
&
_ebss
);
printf
(
"_sstack=%p
\n
"
,
&
_sstack
);
printf
(
"_estack=%p
\n
"
,
&
_estack
);
printf
(
"_ram_start=%p
\n
"
,
&
_ram_start
);
printf
(
"_heap_start=%p
\n
"
,
&
_heap_start
);
printf
(
"_heap_end=%p
\n
"
,
&
_heap_end
);
printf
(
"_ram_end=%p
\n
"
,
&
_ram_end
);
mp_printf
(
print
,
"_etext=%p
\n
"
,
&
_etext
);
mp_printf
(
print
,
"_sidata=%p
\n
"
,
&
_sidata
);
mp_printf
(
print
,
"_sdata=%p
\n
"
,
&
_sdata
);
mp_printf
(
print
,
"_edata=%p
\n
"
,
&
_edata
);
mp_printf
(
print
,
"_sbss=%p
\n
"
,
&
_sbss
);
mp_printf
(
print
,
"_ebss=%p
\n
"
,
&
_ebss
);
mp_printf
(
print
,
"_sstack=%p
\n
"
,
&
_sstack
);
mp_printf
(
print
,
"_estack=%p
\n
"
,
&
_estack
);
mp_printf
(
print
,
"_ram_start=%p
\n
"
,
&
_ram_start
);
mp_printf
(
print
,
"_heap_start=%p
\n
"
,
&
_heap_start
);
mp_printf
(
print
,
"_heap_end=%p
\n
"
,
&
_heap_end
);
mp_printf
(
print
,
"_ram_end=%p
\n
"
,
&
_ram_end
);
}
// qstr info
{
size_t
n_pool
,
n_qstr
,
n_str_data_bytes
,
n_total_bytes
;
qstr_pool_info
(
&
n_pool
,
&
n_qstr
,
&
n_str_data_bytes
,
&
n_total_bytes
);
printf
(
"qstr:
\n
n_pool=%u
\n
n_qstr=%u
\n
n_str_data_bytes=%u
\n
n_total_bytes=%u
\n
"
,
n_pool
,
n_qstr
,
n_str_data_bytes
,
n_total_bytes
);
mp_printf
(
print
,
"qstr:
\n
n_pool=%u
\n
n_qstr=%u
\n
n_str_data_bytes=%u
\n
n_total_bytes=%u
\n
"
,
n_pool
,
n_qstr
,
n_str_data_bytes
,
n_total_bytes
);
}
// GC info
{
gc_info_t
info
;
gc_info
(
&
info
);
printf
(
"GC:
\n
"
);
printf
(
" %u total
\n
"
,
info
.
total
);
printf
(
" %u : %u
\n
"
,
info
.
used
,
info
.
free
);
printf
(
" 1=%u 2=%u m=%u
\n
"
,
info
.
num_1block
,
info
.
num_2block
,
info
.
max_block
);
mp_printf
(
print
,
"GC:
\n
"
);
mp_printf
(
print
,
" %u total
\n
"
,
info
.
total
);
mp_printf
(
print
,
" %u : %u
\n
"
,
info
.
used
,
info
.
free
);
mp_printf
(
print
,
" 1=%u 2=%u m=%u
\n
"
,
info
.
num_1block
,
info
.
num_2block
,
info
.
max_block
);
}
// free space on flash
...
...
@@ -230,7 +231,7 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
fs_user_mount_t
*
vfs_fat
=
MP_OBJ_TO_PTR
(
vfs
->
obj
);
DWORD
nclst
;
f_getfree
(
&
vfs_fat
->
fatfs
,
&
nclst
);
printf
(
"LFS free: %u bytes
\n
"
,
(
uint
)(
nclst
*
vfs_fat
->
fatfs
.
csize
*
512
));
mp_printf
(
print
,
"LFS free: %u bytes
\n
"
,
(
uint
)(
nclst
*
vfs_fat
->
fatfs
.
csize
*
512
));
break
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment