PSoC1 System Supervisor Call - AN2100 Bootloader

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
StEl_289216
Level 2
Level 2
5 replies posted First solution authored First reply posted

I am working on a Flash Write routine which is part of a boot loader for the CY8C27243.  I am using Application AN2100 as a starting point. I have all aspects of the bootloader working except for Flash Write.  After many days of debugging I have narrowed it down to the Supervisor ROM Flash Write sequence which uses the M8C SSC instruction. 

Here is a simplified sequence used to access a supervisor ROM routine as found in FLASHAPI.asm which is part of AN2100. This is part of the temperature table access routine and is a very simple use of the supervisor ROM and should work.

push A   ; save the State variable
push X
mov X, SP   ; copy SP into X
mov A, X     ; mov to A
add A, 3     ; create 3 byte stack frame
mov [0xF9], A   ; save stack frame for supervisory code
mov [0xF8], 0x3A   ; load the supervisory code for flash operations
mov A, 6    ; load A with FLASH_TEMP_TABLE_LOOKUP rom code
SSC          ; SSC call the supervisory code
pop X

Code execution does not return after the SSC instruction. I am assuming it is halting for some reason.

I have double checked all of the parameters and can't figure out what I am doing wrong.  Can SSC only be called when the M8C is in a certain mode ?  I have been able to read Flash successfully since that routine uses the absolute ROM read instruction ROMX which avoids an SCC. I wish there was such an easy way to do a write.

I have been working on this bootloader for nearly a month now and need to finish this before new product release.  

 

0 Likes
1 Solution
StEl_289216
Level 2
Level 2
5 replies posted First solution authored First reply posted

Sampath,

By looking at the compiled code in the .LST file I was able to find the routines for flashwrite and flashread that were located in the application section. By carefully copying these files and adjusting them I was able to make working versions of them that run in the bootloader region. Although it is not the best solution as far as version updating goes, I at least have a working bootloader now that works without any problems.

Thanks, Steve

View solution in original post

0 Likes
10 Replies
SampathS_11
Moderator
Moderator
Moderator
250 sign-ins 250 solutions authored 5 questions asked

Kindly refer to PSoC1 Technical Reference Manual, Page 77, Section 3.1.2.6 TableRead function. Kindly check if all the parameters in Table 3-10 are valid for TableRead command. Usually in most cases, MVI Write page pointer may not be set to the correct value of 0.

Best regards,

Sampath Selvaraj

0 Likes
StEl_289216
Level 2
Level 2
5 replies posted First solution authored First reply posted

Sampath,

Thank you for your reply. The part I am using is a CY827243 which only has 256 bytes of RAM in one page so the MVI Write page pointer is not used or accessible. I have read through the TRM many times, especially Section 3 which I think I have memorized by now. 

I have been able to get the Table Read and the Erase commands to run and return success however the Erase command does not actually erase Flash. When looking at Flash after the command completes, I see that the contents are unchanged. 

Are there any other issues that would prevent an SSC command from working ? Is there a requirement for stack location or other special systems register bits that need to be set a certain way ?

 

Thanks, Steve

 

0 Likes
StEl_289216
Level 2
Level 2
5 replies posted First solution authored First reply posted

Will SSC commands only work after a power on reset ? I can not find any register bits in any of the system registers that apply to a one RAM bank part like the one I am using. I have stripped down the Erase command to the bare minimum hoping to figure out why it does not work. But find it returns success without erasing anything.

 

; State - Erase Block

push X
mov [0xF8], 0x3A   ; load the supervisory code for flash operations
mov X, SP                ;  copy SP into X
mov A, X                  ; mov to A
add A, 3                  ; create 3 byte stack frame
mov [0xF9], A      ; save stack frame for supervisory code
mov A, [X+bARG_BlockId]    ; get ERASE block ID
mov [0xFA], A    ; set block ID
mov A, [X+bDATA_PWErase]
mov [0xFC], A
mov [0xFE], 0x56    ; load the sequence delay count
mov A, 3                     ; load A with specific Flash operation
SSC                         ; SSC call the supervisory code
pop X

; Check the return code for success
cmp [bSSC_ResultCode], bSSC_SUCCESS
jz WriteBlock

0 Likes
StEl_289216
Level 2
Level 2
5 replies posted First solution authored First reply posted

Is there an updated version of AN2100 that is available that may not have been published ?

After almost three weeks of solid frustration, I am at the point where I really doubt that the code in the AN2100 distribution zip file actually works. This has happened to me several times now when developing PSoC based products, the files on the web were old and don't work while apps engineers have updated versions that do work.

 

Or can you give me working versions of flash read/write code for the CY8C27xxx family that are proven to work ?

 

 

0 Likes
lock attach
Attachments are accessible only for community members.

Kindly find attached the projects for CY8C27xxx. These are working projects, which are available in the downloads for AN2100, as a part of AN2100 Bootloader PSoC 1.zip. In the bootloader project, I request you to kindly refer to FLASHAPI.ASM function bFlashWriteBlock starting line 355. Before executing the SSC instruction for Erase Flash, the following steps are performed:

Set Clock

Compute Pulsewidths

I hope this reference will resolve your issue.

Best regards,

Sampath Selvaraj 

0 Likes
StEl_289216
Level 2
Level 2
5 replies posted First solution authored First reply posted

That is the document that I have already, no difference. The routines in flashapi.asm do not work.

I call the pulse width routine and that returns value but when I call the erase routine nothing is erased.

Can you give me ballpark values for pulse width values so I can compare them ?

I think it still boils down to SSC access, I have no way to know if that is working.

I have been a software developer for close to 40 years, been developing PSoC

applications for over 15 years. I know what I am doing. 

I can not get flash erase or write to work. Flash read works fine. No disreprespect intended but, it doesn't look like you have the knowledge to help me. Is there someone there who has experience with accessing the M8C Supervisor ROM routines ? You must have some sort of app note that shows how that is done. There is so much crap in the flashapi routines that it is difficult to understand how the basic SSC command should work.

I can't just take code that I don't understand and put that in a product, I want to understand the basic operation so I can write my own code that is maintainable.

 

0 Likes
StEl_289216
Level 2
Level 2
5 replies posted First solution authored First reply posted

After three weeks of pain, I am finally giving up on AN2100 and will write my own boot loader based on the flashblock library which is used for an EEPROM emulator.  It looks similar to flashapi.asm but all the SSC calls are hidden behind the curtain so I can assume that they will be handled properly.

0 Likes
StEl_289216
Level 2
Level 2
5 replies posted First solution authored First reply posted

I am now using direct calls using the Flashblock API as described in AN2015 and can successfully write and read flash.

As I mentioned previously, the part I am using is the CY8C27243-24PVXI

My bootloader is very close to completion now but I have one last problem. I found that the loader hangs when it  writes a block ID number greater than 0x1F which is address 0x7fc. The problem is that the linker places the bFlashWriteBlock and FlashReadBlock library routines from flashblock.h at 0x78D through 0x91A and the bootloader overwrites this causing the hang.

My bootloader code resides at location 0x3600, is there a way to direct the linker to place the bFlashWriteBlock and FlashReadBlock library routines with the the bootloader code somewhere above 0x3600 ? In reading the imagecrafter compiler manual, I found ways to specify locations for user code and I have used this for my bootloader but I can't find a way to force placement of a library routine, is this possible ?

Thank you

 

 

0 Likes

It is possible to direct the linker to place functions at a different address. It requires directives to be placed in the source files. flashblock.asm is not available directly, but as an object file which is linked with PSoC1 applications.

However, the source code can be found in User Module source code templates. Like for example:

C:\Program Files (x86)\Cypress\PSoC Designer\5.4\Common\CypressSemiDeviceEditor\Data\Stdum\BootLdrI2C\Ver_3_00\Common\Slaveflashblock.asm.

This file however, will require lots of modification. I will try to find if I can get the source code for the same. It will take me some time, since PSoC1 is a mature product, and very few engineers work on PSoC1 anymore. Do kindly bear with me.

 

Best regards,

Sampath Selvaraj

0 Likes
StEl_289216
Level 2
Level 2
5 replies posted First solution authored First reply posted

Sampath,

By looking at the compiled code in the .LST file I was able to find the routines for flashwrite and flashread that were located in the application section. By carefully copying these files and adjusting them I was able to make working versions of them that run in the bootloader region. Although it is not the best solution as far as version updating goes, I at least have a working bootloader now that works without any problems.

Thanks, Steve

0 Likes