On my stm32 mcu there is no eeprom. So, I am using internal flash to save one byte user data to retain it between power cycles.I am doing it the following way,
Add Data section in memory in the linker script
MEMORY {
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K
DATA (xrw) : ORIGIN = 0x800F800, LENGTH = 2K //Allocated one full flash page
}
Create user data section
.user_data :
{ . = ALIGN(4);
*(.user_data)
. = ALIGN(4);
} >DATA
Create a variable to store in flash
attribute((section(".user_data"))) const uint8_t userConfig[10]
Write data using following functions,
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGSERR );
FLASH_PageErase(FLASH_PAGE_31);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, (uint32_t)&userConfig[index], someData);
HAL_FLASH_Lock();
When I try to write to the flash it fails with PGSERR flag set.
0x0800 3800 - 0x0800 3FFF is bank 7 not bank 11.
&userConfig[index] is generally wrong as the memory is programmed in this micro in 64bits words and the address has to be aligned to the 8 bytes boundary.
ALWAYS READ THE DOCUMENTATION before programming microcontrollers. Use of the magic libraries does not free you from knowing your hardware.
I'm attempting to do an exercise from "Expert C Programming" where the point is to see how much memory a program can allocate. It hinges on malloc returning NULL when it cannot allocate anymore.
#include <stdio.h>
#include <stdlib.h>
int main() {
int totalMB = 0;
int oneMeg = 1<<20;
while (malloc(oneMeg)) {
++totalMB;
}
printf("Allocated %d Mb total \n", totalMB);
return 0;
}
Rather than printing the total, I get a kernel panic after allocating ~8GB on my 16GB Macbook Pro.
Kernel panic log:
Anonymous UUID: 0B87CC9D-2495-4639-EA18-6F1F8696029F
Tue Dec 13 23:09:12 2016
*** Panic Report ***
panic(cpu 0 caller 0xffffff800c51f5a4): "zalloc: zone map exhausted while allocating from zone VM map entries, likely due to memory leak in zone VM map entries (6178859600 total bytes, 77235745 elements allocated)"#/Library/Caches/com.apple.xbs/Sources/xnu/xnu-3248.50.21/osfmk/kern/zalloc.c:2628
Backtrace (CPU 0), Frame : Return Address
0xffffff91f89bb960 : 0xffffff800c4dab12
0xffffff91f89bb9e0 : 0xffffff800c51f5a4
0xffffff91f89bbb10 : 0xffffff800c5614e0
0xffffff91f89bbb30 : 0xffffff800c5550e2
0xffffff91f89bbba0 : 0xffffff800c554960
0xffffff91f89bbd90 : 0xffffff800c55f493
0xffffff91f89bbea0 : 0xffffff800c4d17cb
0xffffff91f89bbf10 : 0xffffff800c5b8dca
0xffffff91f89bbfb0 : 0xffffff800c5ecc86
BSD process name corresponding to current thread: a.out
Mac OS version:
15F34
I understand that this can easily be fixed by the doctor's cliche of "It hurts when you do that? Then don't do that" but I want to understand why malloc isn't working as expected.
OS X 10.11.5
For the definitive answer to that question, you can look at the source code, which you'll find here:
zalloc.c source in XNU
In that source file find the function zalloc_internal(). This is the function that gives the kernel panic.
In the function you'll find a "for (;;) {" loop, which basically tries to allocate the memory you're requesting in the specified zone. If there isn't enough space, it immediately tries again. If that fails it does a zone_gc() (garbage collect) to try to reclaim memory. If that also fails, it simply kernel panics - effectively halting the computer.
If you want to understand how zalloc.c works, look up zone-based memory allocators.
Your program is making the kernel run out of space in the zone called "VM map entries", which is a predefined zone allocated at boot. You could probably get the result you are expecting from your program, without a kernel panic, if you allocated more than 1 MB at a time.
In essence it is not really a problem for the kernel to allocate you several gigabytes of memory. However, allocating thousands of smaller allocations summing up to those gigabytes is much harder.
I am trying to leverage the new ConvertFrom-String commandlet in the Windows Management Production Preview 5.
I have a $Sample of the string I am trying to parse data from and the $Template that I am using.
I am getting most of the data that I am looking for but for some reason am not getting all of it.
I have read a number of blog articles about the topic and have trouble shot the parsing with ConvertFrom-String Buddy but am not able to get it to extract all of the data I need.
Can you please give me insight into what I might be doing wrong that is causing most of the data to be captured but not all of it?
Thank you in advance for any help or insight.
PowerShell Version:
PS C:\Users\alozano\Desktop> $psversiontable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10514 6
Here is the powershell code being run:
$Sample = #"
JJK072821.12Z1220126.23630-01.S.JABI
+20.0 DARKNESS
6 IPS PRINT SPEED
+000 TEAR OFF
APPLICATOR PRINT MODE
NON-CONTINUOUS MEDIA TYPE
WEB SENSOR TYPE
DIRECT-THERMAL PRINT METHOD
812 PRINT WIDTH
1874 LABEL LENGTH
9.0IN 228MM MAXIMUM LENGTH
DISABLED SUPPLIES WARNING
MAINT. OFF EARLY WARNING
CONNECTED USB COMM.
READY EXTERNAL 5V
BIDIRECTIONAL PARALLEL COMM.
RS232 SERIAL COMM.
9600 BAUD
8 BITS DATA BITS
NONE PARITY
XON/XOFF HOST HANDSHAKE
NONE PROTOCOL
000 NETWORK ID
NORMAL MODE COMMUNICATIONS
<~> 7EH CONTROL PREFIX
<^> 5EH FORMAT PREFIX
<,> 2CH DELIMITER CHAR
ZPL II ZPL MODE
ACTIVE COMMAND OVERRIDE
NO MOTION MEDIA POWER UP
NO MOTION HEAD CLOSE
OFF BACKFEED
+080 LABEL TOP
+0000 LEFT POSITION
OFF VERIFIER PORT
MODE 1 APPLICATOR PORT
ENABLED ERROR ON PAUSE
PULSE MODE START PRINT SIG
FEED MODE RESYNCH MODE
DISABLED REPRINT MODE
048 WEB S.
079 MEDIA S.
065 RIBBON S.
100 TAKE LABEL
050 MARK S.
000 MARK MED S.
002 TRANS GAIN
040 TRANS BASE
086 TRANS BRIGHT
082 RIBBON GAIN
000 MARK GAIN
DPCSWFX. MODES ENABLED
.......M MODES DISABLED
832 8/MM FULL RESOLUTION
V53.17.21Z <- FIRMWARE
1.3 XML SCHEMA
V45 ---------- 19 HARDWARE ID
CUSTOMIZED CONFIGURATION
10840k...........R: RAM
2048k............E: ONBOARD FLASH
NONE FORMAT CONVERT
*** APPLICATOR P34 INTERFACE
TWINAX/COAX ID
FW VERSION IDLE DISPLAY
11/05/15 RTC DATE
11:22 RTC TIME
DISABLED ZBI
2.1 ZBI VERSION
2,641,289 IN NONRESET CNTR
2,641,289 IN RESET CNTR1
2,641,289 IN RESET CNTR2
6,708,875 CM NONRESET CNTR
6,708,875 CM RESET CNTR1
6,708,875 CM RESET CNTR2
ALL ITEMS PASSWORD LEVEL
"#
$TemplateThatFails = #"
{Zebraconfig*:{Serial:JJK072821.12Z1220126.23630-01.S.JABI}
{Darkness:+20.0} DARKNESS
{PrintSpeed:6 IPS} PRINT SPEED
{TearOff:+000} TEAR OFF
{Applicator:APPLICATOR} PRINT MODE
{MediaType:NON-CONTINUOUS} MEDIA TYPE
{SensorType:WEB} SENSOR TYPE
{PrintMethod:DIRECT-THERMAL} PRINT METHOD
{PrintWidth:812} PRINT WIDTH
{LabelLength:1874} LABEL LENGTH
{MaximumLength:9.0IN 228MM} MAXIMUM LENGTH
{SuppliesWarning:DISABLED} SUPPLIES WARNING
{EarlyWarning:MAINT. OFF} EARLY WARNING
{USBComm:CONNECTED} USB COMM.
{External5v:READY} EXTERNAL 5V
{ParallelComm:BIDIRECTIONAL} PARALLEL COMM.
{SerialComm:RS232} SERIAL COMM.
{Baud:9600} BAUD
{DataBits:8 BITS} DATA BITS
{Parity:NONE} PARITY
{HostHandshake:XON/XOFF} HOST HANDSHAKE
{Protocol:NONE} PROTOCOL
{NetworkID:000} NETWORK ID
{Communications:NORMAL MODE} COMMUNICATIONS
{ControlPrefix:<~> 7EH} CONTROL PREFIX
{FormatPrefix:<^> 5EH} FORMAT PREFIX
{Delimiter:<,> 2CH} DELIMITER CHAR
{ZPLMode:ZPL II} ZPL MODE
{CommandOverride:ACTIVE} COMMAND OVERRIDE
{MediaPowerUp:NO MOTION} MEDIA POWER UP
{HeadClose:NO MOTION} HEAD CLOSE
{Backfeed:OFF} BACKFEED
{LabelTop:+080} LABEL TOP
{LeftPosition:+0000} LEFT POSITION
{VerifierPort:OFF} VERIFIER PORT
{ApplicatorPort:MODE 1} APPLICATOR PORT
{ErrorOnPause:ENABLED} ERROR ON PAUSE
{StartPrintSig:PULSE MODE} START PRINT SIG
{ResynchMode:FEED MODE} RESYNCH MODE
{ReprintMode:DISABLED} REPRINT MODE
{WebSensor:048} WEB S.
{MediaSensor:079} MEDIA S.
{RibbonSensor:065} RIBBON S.
{TakeLabel:100} TAKE LABEL
{MarkSensor:050} MARK S.
{MarkMedSensor:000} MARK MED S.
{TrainsGain:002} TRANS GAIN
{TransBase:040} TRANS BASE
{TransBright:086} TRANS BRIGHT
{RibbonGain:082} RIBBON GAIN
{MarkGain:000} MARK GAIN
{ModesEnable:DPCSWFX.} MODES ENABLED
{ModesDisabled:.......M} MODES DISABLED
{Resolution:832 8/MM FULL} RESOLUTION
{Firmware:V53.17.21Z <-} FIRMWARE
{XMLSchema:1.3} XML SCHEMA
{HardwareID:V45 ---------- 19} HARDWARE ID
{Configuration:CUSTOMIZED} CONFIGURATION
{RAM:10840k...........R:} RAM
{OnboardFlash:2048k............E:} ONBOARD FLASH
{FormatConvert:NONE} FORMAT CONVERT
{P34Interface:*** APPLICATOR} P34 INTERFACE
TWINAX/COAX ID
{IdleDisplay:FW VERSION} IDLE DISPLAY
{RTCDate:11/05/15} RTC DATE
{RTCTime:11:22} RTC TIME
{ZBI:DISABLED} ZBI
{ZBIVersion:2.1} ZBI VERSION
{NonResetCNTRin:2,641,289 IN} NONRESET CNTR
{ResetCNTR1in:2,641,289 IN} RESET CNTR1
{ResetCNTR2in:2,641,289 IN} RESET CNTR2
{NonResetCNTRcm:6,708,875 CM} NONRESET CNTR
{ResetCNTR1cm:6,708,875 CM} RESET CNTR1
{ResetCNTR2cm:6,708,875 CM} RESET CNTR2
{PasswordLevel:ALL ITEMS}} PASSWORD LEVEL
"#
$TemplateThatPartiallyWorks= #"
{Zebraconfig*:{Serial:JJK072821.12Z1220126.23630-01.S.JABI}
{Darkness:+20.0} DARKNESS
{PrintSpeed:6 IPS} PRINT SPEED
{TearOff:+000} TEAR OFF
{Applicator:APPLICATOR} PRINT MODE
{MediaType:NON-CONTINUOUS} MEDIA TYPE
{SensorType:WEB} SENSOR TYPE
{PrintMethod:DIRECT-THERMAL} PRINT METHOD
{PrintWidth:812} PRINT WIDTH
{LabelLength:1874} LABEL LENGTH
{MaximumLength:9.0IN 228MM} MAXIMUM LENGTH
{SuppliesWarning:DISABLED} SUPPLIES WARNING
{EarlyWarning:MAINT. OFF} EARLY WARNING
{USBComm:CONNECTED} USB COMM.
{External5v:READY} EXTERNAL 5V
{ParallelComm:BIDIRECTIONAL} PARALLEL COMM.
{SerialComm:RS232} SERIAL COMM.
{Baud:9600} BAUD
{DataBits:8 BITS} DATA BITS
{Parity:NONE} PARITY
{HostHandshake:XON/XOFF} HOST HANDSHAKE
{Protocol:NONE} PROTOCOL
{NetworkID:000} NETWORK ID
{Communications:NORMAL MODE} COMMUNICATIONS
{ControlPrefix:<~> 7EH} CONTROL PREFIX
{FormatPrefix:<^> 5EH} FORMAT PREFIX
{Delimiter:<,> 2CH} DELIMITER CHAR
{ZPLMode:ZPL II} ZPL MODE
{CommandOverride:ACTIVE} COMMAND OVERRIDE
{MediaPowerUp:NO MOTION} MEDIA POWER UP
{HeadClose:NO MOTION} HEAD CLOSE
{Backfeed:OFF} BACKFEED
{LabelTop:+080} LABEL TOP
{LeftPosition:+0000} LEFT POSITION
{VerifierPort:OFF} VERIFIER PORT
{ApplicatorPort:MODE 1} APPLICATOR PORT
{ErrorOnPause:ENABLED} ERROR ON PAUSE
{StartPrintSig:PULSE MODE} START PRINT SIG
{ResynchMode:FEED MODE} RESYNCH MODE
{ReprintMode:DISABLED} REPRINT MODE
{WebSensor:048} WEB S.
{MediaSensor:079} MEDIA S.
{RibbonSensor:065} RIBBON S.
{TakeLabel:100} TAKE LABEL
{MarkSensor:050} MARK S.
{MarkMedSensor:000} MARK MED S.
{TrainsGain:002} TRANS GAIN
{TransBase:040} TRANS BASE
{TransBright:086} TRANS BRIGHT
{RibbonGain:082} RIBBON GAIN
{MarkGain:000} MARK GAIN
{ModesEnable:DPCSWFX.} MODES ENABLED
{ModesDisabled:.......M} MODES DISABLED
{Resolution:832 8/MM FULL} RESOLUTION
{Firmware:V53.17.21Z <-} FIRMWARE
{XMLSchema:1.3} XML SCHEMA
{HardwareID:V45 ---------- 19} HARDWARE ID
{Configuration:CUSTOMIZED} CONFIGURATION
{RAM:10840k...........R:} RAM
{OnboardFlash:2048k............E:} ONBOARD FLASH
{FormatConvert:NONE} FORMAT CONVERT
{P34Interface:*** APPLICATOR} P34 INTERFACE
TWINAX/COAX ID
{IdleDisplay:FW VERSION} IDLE DISPLAY
{RTCDate:11/05/15} RTC DATE
{RTCTime:11:22} RTC TIME
{ZBI:DISABLED} ZBI
{ZBIVersion:2.1}} ZBI VERSION
"#
Write-Host "Using ConvertFrom-String with the TemplateThatFails"
$Sample | ConvertFrom-String -TemplateContent $TemplateThatFails | select -ExpandProperty ZebraConfig
Write-Host "Using ConvertFrom-String with the TemplateThatPartiallyWorks"
$Sample | ConvertFrom-String -TemplateContent $TemplateThatPartiallyWorks| select -ExpandProperty ZebraConfig
I am getting the following results:
Using ConvertFrom-String with the TemplateThatFails
ConvertFrom-String : ConvertFrom-String appears to be having trouble parsing your data using the template you've provided. We'd love to take a look at what went wrong, if you'd like to share the data and template used to parse it. We've saved these files to
C:\Users\alozano\AppData\Local\Temp\usiqowuu.p2u.input.txt and C:\Users\alozano\AppData\Local\Temp\usiqowuu.p2u-0.template.txt - feel free to attach them in a mail to psdmfb#microsoft.com. We will review all submissions, although we can't guarantee a response.
At line:231 char:16
+ ... codedHTML | ConvertFrom-String -TemplateContent $TemplateThatFails | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [ConvertFrom-String], ResultNotFoundException
+ FullyQualifiedErrorId : ResultNotFound,Microsoft.PowerShell.Commands.StringManipulation.ConvertFromStringCommand
Using ConvertFrom-String with the TemplateThatPartiallyWorks
Serial : JJK072821.12Z1220126.23630-01.S.JABI
Darkness : +20.0
PrintSpeed : 6 IPS
TearOff : +000
Applicator : APPLICATOR
MediaType : NON-CONTINUOUS
SensorType : WEB
PrintMethod : DIRECT-THERMAL
PrintWidth : 812
LabelLength : 1874
MaximumLength : 9.0IN 228MM
SuppliesWarning : DISABLED
EarlyWarning : MAINT. OFF
USBComm : CONNECTED
External5v : READY
ParallelComm : BIDIRECTIONAL
SerialComm : RS232
Baud : 9600
DataBits : 8 BITS
Parity : NONE
HostHandshake : XON/XOFF
Protocol : NONE
NetworkID : 000
Communications : NORMAL MODE
ControlPrefix : <~> 7EH
FormatPrefix : <^> 5EH
Delimiter : <,> 2CH
ZPLMode : ZPL II
CommandOverride : ACTIVE
MediaPowerUp : NO MOTION
HeadClose : NO MOTION
Backfeed : OFF
LabelTop : +080
LeftPosition : +0000
VerifierPort : OFF
ApplicatorPort : MODE 1
ErrorOnPause : ENABLED
StartPrintSig : PULSE MODE
ResynchMode : FEED MODE
ReprintMode : DISABLED
WebSensor : 048
MediaSensor : 079
RibbonSensor : 065
TakeLabel : 100
MarkSensor : 050
MarkMedSensor : 000
TrainsGain : 002
TransBase : 040
TransBright : 086
RibbonGain : 082
MarkGain : 000
ModesEnable : DPCSWFX.
ModesDisabled : .......M
Resolution : 832 8/MM FULL
Firmware : V53.17.21Z <-
XMLSchema : 1.3
HardwareID : V45 ---------- 19
Configuration : CUSTOMIZED
RAM : 10840k...........R:
OnboardFlash : 2048k............E:
FormatConvert : NONE
P34Interface : *** APPLICATOR
IdleDisplay : FW VERSION
RTCDate : 11/05/15
RTCTime : 11:22
ZBI : DISABLED
ZBIVersion : 2.1
These are the 7 lines that are at the end of $TemplateThatFails and that I have left out of $TemplateThatPartiallyWorks:
{NonResetCNTRin:2,641,289 IN} NONRESET CNTR
{ResetCNTR1in:2,641,289 IN} RESET CNTR1
{ResetCNTR2in:2,641,289 IN} RESET CNTR2
{NonResetCNTRcm:6,708,875 CM} NONRESET CNTR
{ResetCNTR1cm:6,708,875 CM} RESET CNTR1
{ResetCNTR2cm:6,708,875 CM} RESET CNTR2
{PasswordLevel:ALL ITEMS}} PASSWORD LEVEL
System Info:
Operating System: Windows 8.1 Enterprise 64-bit (6.3, Build 9600) (9600.winblue_r9.150322-1500)
Language: English (Regional Setting: English)
System Manufacturer: Dell Inc.
System Model: Latitude E7450
BIOS: BIOS Date: 12/29/14 05:36:41 Ver: A02.00
Processor: Intel(R) Core(TM) i5-5300U CPU # 2.30GHz (4 CPUs), ~2.3GHz
Memory: 8192MB RAM
Available OS Memory: 8082MB RAM
My setup is quite the same (i5/16Gb/Win8.1 64bit/PS 5.0.10514.6).
This is a bit crazy ; only the last line is a problem.
1 - If you isolate it completely and make it the only line in the template and in the sample, it works.
Code :
$Sample = #"
ALL ITEMS PASSWORD LEVEL
"#
$TemplateThatFails = #"
{Zebraconfig*:{PasswordLevel:ALL ITEMS}} PASSWORD LEVEL
"#
Write-Host "Using ConvertFrom-String with the TemplateThatFails"
$startTime = Get-Date
$Sample | ConvertFrom-String -TemplateContent $TemplateThatFails | select -ExpandProperty ZebraConfig
$endTime = Get-Date
$elapsed = "{0:N2}" -f (New-TimeSpan $startTime $endTime).TotalSeconds
"$elapsed seconds elapsed"
Output :
PasswordLevel
-------------
ALL ITEMS
0,13 seconds elapsed
2 - If you move it just above the previous one (in the sample and in the template), you don't get any error but the data is mixed up.
Code :
$Sample = #"
JJK072821.12Z1220126.23630-01.S.JABI
+20.0 DARKNESS
6 IPS PRINT SPEED
+000 TEAR OFF
APPLICATOR PRINT MODE
NON-CONTINUOUS MEDIA TYPE
WEB SENSOR TYPE
DIRECT-THERMAL PRINT METHOD
812 PRINT WIDTH
1874 LABEL LENGTH
9.0IN 228MM MAXIMUM LENGTH
DISABLED SUPPLIES WARNING
MAINT. OFF EARLY WARNING
CONNECTED USB COMM.
READY EXTERNAL 5V
BIDIRECTIONAL PARALLEL COMM.
RS232 SERIAL COMM.
9600 BAUD
8 BITS DATA BITS
NONE PARITY
XON/XOFF HOST HANDSHAKE
NONE PROTOCOL
000 NETWORK ID
NORMAL MODE COMMUNICATIONS
<~> 7EH CONTROL PREFIX
<^> 5EH FORMAT PREFIX
<,> 2CH DELIMITER CHAR
ZPL II ZPL MODE
ACTIVE COMMAND OVERRIDE
NO MOTION MEDIA POWER UP
NO MOTION HEAD CLOSE
OFF BACKFEED
+080 LABEL TOP
+0000 LEFT POSITION
OFF VERIFIER PORT
MODE 1 APPLICATOR PORT
ENABLED ERROR ON PAUSE
PULSE MODE START PRINT SIG
FEED MODE RESYNCH MODE
DISABLED REPRINT MODE
048 WEB S.
079 MEDIA S.
065 RIBBON S.
100 TAKE LABEL
050 MARK S.
000 MARK MED S.
002 TRANS GAIN
040 TRANS BASE
086 TRANS BRIGHT
082 RIBBON GAIN
000 MARK GAIN
DPCSWFX. MODES ENABLED
.......M MODES DISABLED
832 8/MM FULL RESOLUTION
V53.17.21Z <- FIRMWARE
1.3 XML SCHEMA
V45 ---------- 19 HARDWARE ID
CUSTOMIZED CONFIGURATION
10840k...........R: RAM
2048k............E: ONBOARD FLASH
NONE FORMAT CONVERT
*** APPLICATOR P34 INTERFACE
TWINAX/COAX ID
FW VERSION IDLE DISPLAY
11/05/15 RTC DATE
11:22 RTC TIME
DISABLED ZBI
2.1 ZBI VERSION
2,641,289 IN NONRESET CNTR
2,641,289 IN RESET CNTR1
2,641,289 IN RESET CNTR2
6,708,875 CM NONRESET CNTR
6,708,875 CM RESET CNTR1
ALL ITEMS PASSWORD LEVEL
6,708,875 CM RESET CNTR2
"#
$TemplateThatFails = #"
{Zebraconfig*:{Serial:JJK072821.12Z1220126.23630-01.S.JABI}
{Darkness:+20.0} DARKNESS
{PrintSpeed:6 IPS} PRINT SPEED
{TearOff:+000} TEAR OFF
{Applicator:APPLICATOR} PRINT MODE
{MediaType:NON-CONTINUOUS} MEDIA TYPE
{SensorType:WEB} SENSOR TYPE
{PrintMethod:DIRECT-THERMAL} PRINT METHOD
{PrintWidth:812} PRINT WIDTH
{LabelLength:1874} LABEL LENGTH
{MaximumLength:9.0IN 228MM} MAXIMUM LENGTH
{SuppliesWarning:DISABLED} SUPPLIES WARNING
{EarlyWarning:MAINT. OFF} EARLY WARNING
{USBComm:CONNECTED} USB COMM.
{External5v:READY} EXTERNAL 5V
{ParallelComm:BIDIRECTIONAL} PARALLEL COMM.
{SerialComm:RS232} SERIAL COMM.
{Baud:9600} BAUD
{DataBits:8 BITS} DATA BITS
{Parity:NONE} PARITY
{HostHandshake:XON/XOFF} HOST HANDSHAKE
{Protocol:NONE} PROTOCOL
{NetworkID:000} NETWORK ID
{Communications:NORMAL MODE} COMMUNICATIONS
{ControlPrefix:<~> 7EH} CONTROL PREFIX
{FormatPrefix:<^> 5EH} FORMAT PREFIX
{Delimiter:<,> 2CH} DELIMITER CHAR
{ZPLMode:ZPL II} ZPL MODE
{CommandOverride:ACTIVE} COMMAND OVERRIDE
{MediaPowerUp:NO MOTION} MEDIA POWER UP
{HeadClose:NO MOTION} HEAD CLOSE
{Backfeed:OFF} BACKFEED
{LabelTop:+080} LABEL TOP
{LeftPosition:+0000} LEFT POSITION
{VerifierPort:OFF} VERIFIER PORT
{ApplicatorPort:MODE 1} APPLICATOR PORT
{ErrorOnPause:ENABLED} ERROR ON PAUSE
{StartPrintSig:PULSE MODE} START PRINT SIG
{ResynchMode:FEED MODE} RESYNCH MODE
{ReprintMode:DISABLED} REPRINT MODE
{WebSensor:048} WEB S.
{MediaSensor:079} MEDIA S.
{RibbonSensor:065} RIBBON S.
{TakeLabel:100} TAKE LABEL
{MarkSensor:050} MARK S.
{MarkMedSensor:000} MARK MED S.
{TrainsGain:002} TRANS GAIN
{TransBase:040} TRANS BASE
{TransBright:086} TRANS BRIGHT
{RibbonGain:082} RIBBON GAIN
{MarkGain:000} MARK GAIN
{ModesEnable:DPCSWFX.} MODES ENABLED
{ModesDisabled:.......M} MODES DISABLED
{Resolution:832 8/MM FULL} RESOLUTION
{Firmware:V53.17.21Z <-} FIRMWARE
{XMLSchema:1.3} XML SCHEMA
{HardwareID:V45 ---------- 19} HARDWARE ID
{Configuration:CUSTOMIZED} CONFIGURATION
{RAM:10840k...........R:} RAM
{OnboardFlash:2048k............E:} ONBOARD FLASH
{FormatConvert:NONE} FORMAT CONVERT
{P34Interface:*** APPLICATOR} P34 INTERFACE
TWINAX/COAX ID
{IdleDisplay:FW VERSION} IDLE DISPLAY
{RTCDate:11/05/15} RTC DATE
{RTCTime:11:22} RTC TIME
{ZBI:DISABLED} ZBI
{ZBIVersion:2.1} ZBI VERSION
{NonResetCNTRin:2,641,289 IN} NONRESET CNTR
{ResetCNTR1in:2,641,289 IN} RESET CNTR1
{ResetCNTR2in:2,641,289 IN} RESET CNTR2
{NonResetCNTRcm:6,708,875 CM} NONRESET CNTR
{ResetCNTR1cm:6,708,875 CM} RESET CNTR1
{PasswordLevel:ALL ITEMS} PASSWORD LEVEL
{ResetCNTR2cm:6,708,875 CM}} RESET CNTR2
"#
Write-Host "Using ConvertFrom-String with the TemplateThatFails"
$startTime = Get-Date
$Sample | ConvertFrom-String -TemplateContent $TemplateThatFails | select -ExpandProperty ZebraConfig
$endTime = Get-Date
$elapsed = "{0:N2}" -f (New-TimeSpan $startTime $endTime).TotalSeconds
"$elapsed seconds elapsed"
Output :
Serial : JJK072821.12Z1220126.23630-01.S.JABI
Darkness : +20.0
PrintSpeed : 6 IPS
TearOff : +000
Applicator : APPLICATOR
MediaType : NON-CONTINUOUS
SensorType : WEB
PrintMethod : DIRECT-THERMAL
PrintWidth : 812
LabelLength : 1874
MaximumLength : 9.0IN 228MM
SuppliesWarning : DISABLED
EarlyWarning : MAINT. OFF
USBComm : CONNECTED
External5v : READY
ParallelComm : BIDIRECTIONAL
SerialComm : RS232
Baud : 9600
DataBits : 8 BITS
Parity : NONE
HostHandshake : XON/XOFF
Protocol : NONE
NetworkID : 000
Communications : NORMAL MODE
ControlPrefix : <~> 7EH
FormatPrefix : <^> 5EH
Delimiter : <,> 2CH
ZPLMode : ZPL II
CommandOverride : ACTIVE
MediaPowerUp : NO MOTION
HeadClose : NO MOTION
Backfeed : OFF
LabelTop : +080
LeftPosition : +0000
VerifierPort : OFF
ApplicatorPort : MODE 1
ErrorOnPause : ENABLED
StartPrintSig : PULSE MODE
ResynchMode : FEED MODE
ReprintMode : DISABLED
WebSensor : 048
MediaSensor : 079
RibbonSensor : 065
TakeLabel : 100
MarkSensor : 050
MarkMedSensor : 000
TrainsGain : 002
TransBase : 040
TransBright : 086
RibbonGain : 082
MarkGain : 000
ModesEnable : DPCSWFX.
ModesDisabled : .......M
Resolution : 832 8/MM FULL
Firmware : V53.17.21Z <-
XMLSchema : 1.3
HardwareID : V45 ---------- 19
Configuration : CUSTOMIZED
RAM : 10840k...........R:
OnboardFlash : 2048k............E:
FormatConvert : NONE
P34Interface : *** APPLICATOR
IdleDisplay : FW VERSION
RTCDate : 11/05/15
RTCTime : 11:22
ZBI : DISABLED
ZBIVersion : 2.1
NonResetCNTRin : 2,641,289 IN
ResetCNTR1in : 2,641,289 IN
ResetCNTR2in : 2,641,289 IN
NonResetCNTRcm : 6,708,875 CM
ResetCNTR1cm : 6,708,875 CM
PasswordLevel : CM RESET
ResetCNTR2cm : 6,708,875 CM
36,58 seconds elapsed
3 - If you move it above ZBI VERSION (sample + template), which is the last line in the partially working template, everything is fine.
Code :
$Sample = #"
JJK072821.12Z1220126.23630-01.S.JABI
+20.0 DARKNESS
6 IPS PRINT SPEED
+000 TEAR OFF
APPLICATOR PRINT MODE
NON-CONTINUOUS MEDIA TYPE
WEB SENSOR TYPE
DIRECT-THERMAL PRINT METHOD
812 PRINT WIDTH
1874 LABEL LENGTH
9.0IN 228MM MAXIMUM LENGTH
DISABLED SUPPLIES WARNING
MAINT. OFF EARLY WARNING
CONNECTED USB COMM.
READY EXTERNAL 5V
BIDIRECTIONAL PARALLEL COMM.
RS232 SERIAL COMM.
9600 BAUD
8 BITS DATA BITS
NONE PARITY
XON/XOFF HOST HANDSHAKE
NONE PROTOCOL
000 NETWORK ID
NORMAL MODE COMMUNICATIONS
<~> 7EH CONTROL PREFIX
<^> 5EH FORMAT PREFIX
<,> 2CH DELIMITER CHAR
ZPL II ZPL MODE
ACTIVE COMMAND OVERRIDE
NO MOTION MEDIA POWER UP
NO MOTION HEAD CLOSE
OFF BACKFEED
+080 LABEL TOP
+0000 LEFT POSITION
OFF VERIFIER PORT
MODE 1 APPLICATOR PORT
ENABLED ERROR ON PAUSE
PULSE MODE START PRINT SIG
FEED MODE RESYNCH MODE
DISABLED REPRINT MODE
048 WEB S.
079 MEDIA S.
065 RIBBON S.
100 TAKE LABEL
050 MARK S.
000 MARK MED S.
002 TRANS GAIN
040 TRANS BASE
086 TRANS BRIGHT
082 RIBBON GAIN
000 MARK GAIN
DPCSWFX. MODES ENABLED
.......M MODES DISABLED
832 8/MM FULL RESOLUTION
V53.17.21Z <- FIRMWARE
1.3 XML SCHEMA
V45 ---------- 19 HARDWARE ID
CUSTOMIZED CONFIGURATION
10840k...........R: RAM
2048k............E: ONBOARD FLASH
NONE FORMAT CONVERT
*** APPLICATOR P34 INTERFACE
TWINAX/COAX ID
FW VERSION IDLE DISPLAY
11/05/15 RTC DATE
11:22 RTC TIME
DISABLED ZBI
ALL ITEMS PASSWORD LEVEL
2.1 ZBI VERSION
2,641,289 IN NONRESET CNTR
2,641,289 IN RESET CNTR1
2,641,289 IN RESET CNTR2
6,708,875 CM NONRESET CNTR
6,708,875 CM RESET CNTR1
6,708,875 CM RESET CNTR2
"#
$TemplateThatFails = #"
{Zebraconfig*:{Serial:JJK072821.12Z1220126.23630-01.S.JABI}
{Darkness:+20.0} DARKNESS
{PrintSpeed:6 IPS} PRINT SPEED
{TearOff:+000} TEAR OFF
{Applicator:APPLICATOR} PRINT MODE
{MediaType:NON-CONTINUOUS} MEDIA TYPE
{SensorType:WEB} SENSOR TYPE
{PrintMethod:DIRECT-THERMAL} PRINT METHOD
{PrintWidth:812} PRINT WIDTH
{LabelLength:1874} LABEL LENGTH
{MaximumLength:9.0IN 228MM} MAXIMUM LENGTH
{SuppliesWarning:DISABLED} SUPPLIES WARNING
{EarlyWarning:MAINT. OFF} EARLY WARNING
{USBComm:CONNECTED} USB COMM.
{External5v:READY} EXTERNAL 5V
{ParallelComm:BIDIRECTIONAL} PARALLEL COMM.
{SerialComm:RS232} SERIAL COMM.
{Baud:9600} BAUD
{DataBits:8 BITS} DATA BITS
{Parity:NONE} PARITY
{HostHandshake:XON/XOFF} HOST HANDSHAKE
{Protocol:NONE} PROTOCOL
{NetworkID:000} NETWORK ID
{Communications:NORMAL MODE} COMMUNICATIONS
{ControlPrefix:<~> 7EH} CONTROL PREFIX
{FormatPrefix:<^> 5EH} FORMAT PREFIX
{Delimiter:<,> 2CH} DELIMITER CHAR
{ZPLMode:ZPL II} ZPL MODE
{CommandOverride:ACTIVE} COMMAND OVERRIDE
{MediaPowerUp:NO MOTION} MEDIA POWER UP
{HeadClose:NO MOTION} HEAD CLOSE
{Backfeed:OFF} BACKFEED
{LabelTop:+080} LABEL TOP
{LeftPosition:+0000} LEFT POSITION
{VerifierPort:OFF} VERIFIER PORT
{ApplicatorPort:MODE 1} APPLICATOR PORT
{ErrorOnPause:ENABLED} ERROR ON PAUSE
{StartPrintSig:PULSE MODE} START PRINT SIG
{ResynchMode:FEED MODE} RESYNCH MODE
{ReprintMode:DISABLED} REPRINT MODE
{WebSensor:048} WEB S.
{MediaSensor:079} MEDIA S.
{RibbonSensor:065} RIBBON S.
{TakeLabel:100} TAKE LABEL
{MarkSensor:050} MARK S.
{MarkMedSensor:000} MARK MED S.
{TrainsGain:002} TRANS GAIN
{TransBase:040} TRANS BASE
{TransBright:086} TRANS BRIGHT
{RibbonGain:082} RIBBON GAIN
{MarkGain:000} MARK GAIN
{ModesEnable:DPCSWFX.} MODES ENABLED
{ModesDisabled:.......M} MODES DISABLED
{Resolution:832 8/MM FULL} RESOLUTION
{Firmware:V53.17.21Z <-} FIRMWARE
{XMLSchema:1.3} XML SCHEMA
{HardwareID:V45 ---------- 19} HARDWARE ID
{Configuration:CUSTOMIZED} CONFIGURATION
{RAM:10840k...........R:} RAM
{OnboardFlash:2048k............E:} ONBOARD FLASH
{FormatConvert:NONE} FORMAT CONVERT
{P34Interface:*** APPLICATOR} P34 INTERFACE
TWINAX/COAX ID
{IdleDisplay:FW VERSION} IDLE DISPLAY
{RTCDate:11/05/15} RTC DATE
{RTCTime:11:22} RTC TIME
{ZBI:DISABLED} ZBI
{PasswordLevel:ALL ITEMS} PASSWORD LEVEL
{ZBIVersion:2.1} ZBI VERSION
{NonResetCNTRin:2,641,289 IN} NONRESET CNTR
{ResetCNTR1in:2,641,289 IN} RESET CNTR1
{ResetCNTR2in:2,641,289 IN} RESET CNTR2
{NonResetCNTRcm:6,708,875 CM} NONRESET CNTR
{ResetCNTR1cm:6,708,875 CM} RESET CNTR1
{ResetCNTR2cm:6,708,875 CM}} RESET CNTR2
"#
Write-Host "Using ConvertFrom-String with the TemplateThatFails"
$startTime = Get-Date
$Sample | ConvertFrom-String -TemplateContent $TemplateThatFails | select -ExpandProperty ZebraConfig
$endTime = Get-Date
$elapsed = "{0:N2}" -f (New-TimeSpan $startTime $endTime).TotalSeconds
"$elapsed seconds elapsed"
Output :
Serial : JJK072821.12Z1220126.23630-01.S.JABI
Darkness : +20.0
PrintSpeed : 6 IPS
TearOff : +000
Applicator : APPLICATOR
MediaType : NON-CONTINUOUS
SensorType : WEB
PrintMethod : DIRECT-THERMAL
PrintWidth : 812
LabelLength : 1874
MaximumLength : 9.0IN 228MM
SuppliesWarning : DISABLED
EarlyWarning : MAINT. OFF
USBComm : CONNECTED
External5v : READY
ParallelComm : BIDIRECTIONAL
SerialComm : RS232
Baud : 9600
DataBits : 8 BITS
Parity : NONE
HostHandshake : XON/XOFF
Protocol : NONE
NetworkID : 000
Communications : NORMAL MODE
ControlPrefix : <~> 7EH
FormatPrefix : <^> 5EH
Delimiter : <,> 2CH
ZPLMode : ZPL II
CommandOverride : ACTIVE
MediaPowerUp : NO MOTION
HeadClose : NO MOTION
Backfeed : OFF
LabelTop : +080
LeftPosition : +0000
VerifierPort : OFF
ApplicatorPort : MODE 1
ErrorOnPause : ENABLED
StartPrintSig : PULSE MODE
ResynchMode : FEED MODE
ReprintMode : DISABLED
WebSensor : 048
MediaSensor : 079
RibbonSensor : 065
TakeLabel : 100
MarkSensor : 050
MarkMedSensor : 000
TrainsGain : 002
TransBase : 040
TransBright : 086
RibbonGain : 082
MarkGain : 000
ModesEnable : DPCSWFX.
ModesDisabled : .......M
Resolution : 832 8/MM FULL
Firmware : V53.17.21Z <-
XMLSchema : 1.3
HardwareID : V45 ---------- 19
Configuration : CUSTOMIZED
RAM : 10840k...........R:
OnboardFlash : 2048k............E:
FormatConvert : NONE
P34Interface : *** APPLICATOR
IdleDisplay : FW VERSION
RTCDate : 11/05/15
RTCTime : 11:22
ZBI : DISABLED
PasswordLevel : ALL ITEMS
ZBIVersion : 2.1
NonResetCNTRin : 2,641,289 IN
ResetCNTR1in : 2,641,289 IN
ResetCNTR2in : 2,641,289 IN
NonResetCNTRcm : 6,708,875 CM
ResetCNTR1cm : 6,708,875 CM
ResetCNTR2cm : 6,708,875 CM
36,32 seconds elapsed
I really don't understand what's going on, but I have managed to suppress the error so I hope this will point you in the right direction.
PS : why is this so long to run ?!
Have some issues with passing large amount of data (3 MB) from uboot to linux kernel 2.6.35.3 on imx50 ARM board. This data is required in kernel device driver probe function and then it should be released. First uboot load data from flash to RAM, then pass physical address for linux kernel using bootargs. In kernel I try to reserve certain amount of memory using reserve_resource() in arch/arm/kernel/setup.c file:
--- a/arch/arm/kernel/setup.c Tue Jul 17 11:22:39 2012 +0300
+++ b/arch/arm/kernel/setup.c Fri Jul 20 14:17:16 2012 +0300
struct resource my_mem_res = {
.name = "My_Region",
.start = 0x77c00000,
.end = 0x77ffffff,
.flags = IORESOURCE_MEM | IORESOURCE_BUSY,
};
## -477,6 +479,10 ##
kernel_code.end = virt_to_phys(_etext - 1);
kernel_data.start = virt_to_phys(_data);
kernel_data.end = virt_to_phys(_end - 1);
+ my_mem_res.start = mi->bank[i].start + mi->bank[i].size - 0x400000;
+ my_mem_res.end = mi->bank[i].start + mi->bank[i].size - 1;
for (i = 0; i < mi->nr_banks; i++) {
if (mi->bank[i].size == 0)
## -496,6 +502,8 ##
if (kernel_data.start >= res->start &&
kernel_data.end <= res->end)
request_resource(res, &kernel_data);
+
+ request_resource(res, &my_mem_res);
}
if (mdesc->video_start) {
By this I'm trying to tell kernel that this memory area it reserved and this data should not be modified by kernel.
70000000-77ffffff : System RAM
70027000-7056ffff : Kernel text
70588000-7062094f : Kernel data
77c00000-77ffffff : My_Region
In driver ioremap(0x77c00000, AREA_SIZE) is used to get kernel memory address. But when I dump content of memory, there is only zeros. If boot kernel with mem=120M (total 128MB RAM is avaliable), then my data is above kernel system ram region, then I get data I expect.
So, my questions:
Why I get zeros and how do I pass large amount of binary data from uboot to linux kernel?
You could use a custom ATAG to either pass the data block or to pass the address & length of the data. Note that the "A" in ATAG stands for ARM, so this solution is not portable to other architectures. An ATAG is preferable to a command-line bootarg IMO because you do not want the user to muck with physical memory addresses. Also the Linux kernel will process the ATAG list before the MMU (i.e. virtual memory) is enabled.
In U-Boot, look at lib_arm/armlinux.c or arch/arm/lib/bootm.c for routines that build the ARM tag list. Write your own routine for your new tag(s), and then invoke it in do_bootm_linux().
In the Linux kernel ATAGs are processed in arch/arm/kernel/setup.c, when virtual memory has not yet been enabled. If you just pass an address & length values from U-Boot, then the pointer & length can be assigned to global variables that are exported,
void *my_data;
unsigned int my_dlen;
EXPORT_SYMBOL(my_data);
EXPORT_SYMBOL(my_dlen);
and then the driver can retrieve it.
extern void *my_data;
extern unsigned int my_dlen;
request_mem_region(my_data, my_dlen, DRV_NAME);
md_map = ioremap(my_data, my_dlen);
I've used similar code to probe for SRAM in U-Boot, then pass the starting address & number of KBytes found to the kernel in a custom ATAG. A kernel driver obtains these values, and if they are nonzero and have sane values, creates a block device out of the SRAM. The major difference from your situation is that the SRAM is in a completely different physical address range from the SDRAM.
NOTE
An ATAG is built by U-Boot for the physical memory that the kernel can use, so this is really where you need to define and exclude your reserved RAM. It's probably too late to do that in the kernel.